How to set ViewPoint for the Map

Hi…
I want to set ViewPoint (NorthWest & SouthEast) to the Map. Because im using Google GeoLocation. So, the search results has the ViewPoint value for the Search Location. How to set the Bound in the Map of OSM…?

Hi, @Narayanan

The current version of the GeoMap UI component does not provide a method for specifying the bounds of the map. We will add this setting in the next release.

As a workaround, you can retrieve the embedded Leaflet component and set the bounds using its API:

    @Inject
    private GeoMap map;

    @Subscribe
    private void onInit(InitEvent event) {
        LMap leafletMap = map.unwrap(LMap.class);

        Point jtsPoint1 = GeometryUtils.createPoint(-0.189290, 51.530358); //lon, lat
        Point jtsPoint2 = GeometryUtils.createPoint(-0.018702, 51.463019);

        Bounds bounds = new Bounds(
                JTSUtil.toLeafletPoint(jtsPoint1),
                JTSUtil.toLeafletPoint(jtsPoint2));
        leafletMap.zoomToExtent(bounds);
    }

UPDATE:
In the 1.3 version this method was added to GeoMap:
zoomToBounds(Point topLeft, Point bottomRight).