You can save your markers in Map<String Marker> , using the title as a key:
private Map<String, Marker> markers = new HashMap<>();
When you add markers to the map, you also need to add them to the hashmap:
String markerTitle = "My Marker"; LatLng markerPosition = new LatLng(26.89454, 75.82607); Marker marker = mMap.addMarker(new MarkerOptions().position(markerPosition).title(markerTitle)); markers.put(markerTitle, marker);
Then you can center the marker by requesting a hash map:
private void centerMarker(String title) { Marker marker = markers.get(title); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), 15f)); }
source share