New basemap styling is coming soon to Google Maps Platform. This update to map styling includes a new default color palette, modernized pins, and improvements to map experiences and usability. All map styles will be automatically updated in March 2025. For more information on availability and how to opt in earlier, see New map style for Google Maps Platform.
Stay organized with collections
Save and categorize content based on your preferences.
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.
If Google Play services is not installed on the device, the user will be prompted to install
it, and the onMapReady(GoogleMap) method will only be triggered when the user has
installed it and returned to the app.
public
abstract
void
onMapReady(GoogleMap googleMap)
Called when the map is ready to be used.
Note that this does not guarantee that the map has undergone layout. Therefore, the map's
size may not have been determined by the time the callback method is called. If you need to
know the dimensions or call a method in the API that needs to know the dimensions, get the
map's View and register an ViewTreeObserver.OnGlobalLayoutListener as well.
Do not chain the OnMapReadyCallback and OnGlobalLayoutListener listeners,
but instead register and wait for both callbacks independently, since the callbacks can be
fired in any order.
As an example, if you want to update the map's camera using a LatLngBounds without dimensions, you should wait until both
OnMapReadyCallback and OnGlobalLayoutListener have completed. Otherwise there
is a race condition that could trigger an IllegalStateException.
Parameters
googleMap
A non-null instance of a GoogleMap associated with the MapFragment or
MapView that defines the callback.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-01-14 UTC."],[[["`OnMapReadyCallback` is triggered when the Google Map is fully loaded and ready for interaction within a `MapFragment` or `MapView`."],["It provides a non-null `GoogleMap` object in the `onMapReady` method, enabling developers to manipulate the map."],["If Google Play services is not available, users are prompted to install it before the callback is triggered."],["The map's layout and dimensions might not be immediately available in `onMapReady`, requiring the use of `ViewTreeObserver.OnGlobalLayoutListener` for size-dependent operations."],["Avoid chaining `OnMapReadyCallback` and `OnGlobalLayoutListener`, handle them independently to prevent race conditions and potential `IllegalStateException`."]]],[]]