Reputation: 1135
In google maps
I want to fix my camera to a particular country. I don't need whole worlds Mercator projection. So I need to set LatLngBounds
in my google maps. How can I find LatLngBounds
of a particular region?
Here is my code but it's not setting LatLngBounds
as my expectation set's constraints on right side.
LatLng v1= new LatLng(24.044982389517603,89.75482430309057);
LatLng v2 = new LatLng(22.309956868003045,91.20187237858772);
LatLngBounds BANGLADESH = new LatLngBounds(
v2,v1
);
mMap.setLatLngBoundsForCameraTarget(BANGLADESH);
Upvotes: 0
Views: 1132
Reputation: 13353
You can get country boundaries once from openstreetmap.org like described in this article of Pēteris Ņikiforovs or by http://polygons.openstreetmap.fr/get_poly.py?id=184640¶ms=0 and add it as polygon points find LatLngBounds
like you do it:
...
Builder builder = new LatLngBounds.Builder();
for(int i = 0 ; i < N_POINTS; i++) {
builder.include(new LatLng(lat, lng));
}
LatLngBounds BANGLADESH = new LatLngBounds = builder.build();
int padding = 15; // offset from edges of the map in pixels
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(BANGLADESH, padding);
mMap.moveCamera(cameraUpdate );
...
Upvotes: 0