Getting particular location of google map in center in android studio
I used this code to get particular location in center.
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(33.7167, 73.0667), 4))
It worked somehow but after putting 30 no of markers simultaneously. I didn't get location in center.
this is my snippet of code
You can update camera to the center of bounds of markers. For that -
Create LatLngBounds.Builder object and add all the markers in it.
LatLngBounds.Builder builder = new LatLngBounds.Builder();
While adding marker store it to variable like
Marker marker1 = mMap.addMarker(....); Marker marker2 = mMap.addMarker(....);
Then add all markers in it using
Then build LatLngBounds
LatLngBounds bounds = builder.build();
Then create CameraUpdate and animate camera to relative position
int padding = 0; // offset from edges of the map in pixels CameraUpdate camUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding); mMap.animateCamera(camUpdate);
Refer this answer for more details.
Hope it'll work.