While working a ViewHolder of GoogleMap Lite, as part of the row in RecyclerView, I'm looking for callback to set the pins location when the Map is ready. I found both function below.
OnMapLoadedCallback : https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapLoadedCallback?hl=en
OnMapReadyCallback : https://developers.google.com/android/reference/com/google/android/gms/maps/OnMapReadyCallback
Both also proven working and usable (as shown below). Hence I'm puzzled if they do have any specific different behaviour that should be used at different occasion, or they are indeed similar and could be used interchangably?
The use of OnMapLoadedCallback:
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Marker marker : markers) {
builder.include(marker.getPosition());
}
final CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(builder.build(), 0);
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
googleMap.moveCamera(cameraUpdate);
}
});
The use of OnMapReadyCallback:
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Marker marker : markers) {
builder.include(marker.getPosition());
}
final CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(builder.build(), 0);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.moveCamera(cameraUpdate);
}
});
Thanks!!