Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android maps: difference between OnMapReady() and OnMapLoaded()

Can anyone explain the difference between

OnMapReadyCallback.OnMapReady(GoogleMap googleMap)

and

GoogleMap.OnMapLoadedCallback.OnMapLoaded()

It is not very clear to me.

like image 677
Daniele B Avatar asked Aug 30 '16 16:08

Daniele B


People also ask

What is onMapReady?

public interface OnMapReadyCallback. Callback interface for when the map is ready to be used. Once an instance of this interface is set on a MapFragment or MapView object, the onMapReady(GoogleMap) method is triggered when the map is ready to be used and provides a non-null instance of GoogleMap .


1 Answers

It basically depends upon what you want to do with the map.

You can safely use OnMapReadyCallback to set your pins, etc. It is called as soon as the map is ready for you to use it.

OnMapLoadedCallback, as the docs state, is called

When the map has finished rendering. This occurs after all tiles required to render the map have been fetched, and all labeling is complete. eg. the map's content is fully loaded and visible.

This happens later than OnMapReady. The call googleMap.setOnMapLoadedCallback even implies that OnMapReady already happened to be able to be called safely (googleMap != null).

like image 71
Gaurav Sarma Avatar answered Nov 15 '22 10:11

Gaurav Sarma