Page Summary
-
GoogleMap.OnMyLocationButtonClickListeneris an interface used to handle clicks on the "My Location" button within a Google Map. -
The primary method,
onMyLocationButtonClick(), is called when the button is clicked and allows custom actions before the default camera centering on the user's location. -
Returning
truefromonMyLocationButtonClick()prevents the default camera movement, while returningfalseallows it. -
For obtaining the user's location, it's recommended to use
FusedLocationProviderApiorRoadSnappedLocationProviderfor road-snapped locations.
Callback interface for when the My Location button is clicked.
Public Method Summary
| abstract boolean |
onMyLocationButtonClick()
Called when the my location button is clicked.
|
Public Methods
public abstract boolean onMyLocationButtonClick ()
Called when the my location button is clicked.
This is called on the Android UI thread.
Use com.google.android.gms.location.FusedLocationProviderApi if you need to obtain the user's current location. Use RoadSnappedLocationProvider if you need to obtain the user's current location, snapped to the road network.
Returns
trueif the listener has consumed the event (i.e., the default behavior should not occur);falseotherwise (i.e., the default behavior should occur). The default behavior is for the camera move such that it is centered on the user location.