public final class LocationComponent extends Object
RenderMode.NORMAL
simply shows the users location on the map
represented as a dot. RenderMode.COMPASS
mode allows you to display an arrow icon
(by default) that points in the direction the device is pointing in.
RenderMode.GPS
can be used in conjunction with our Navigation SDK to
display a larger icon (customized with LocationComponentOptions.gpsDrawable()
) we call the user puck.
This component also offers the ability to set a map camera behavior for tracking the user
location. These different CameraMode
s will track, stop tracking the location based on the
mode set with setCameraMode(int)
.
To get the component object use MapboxMap.getLocationComponent()
and activate it with
activateLocationComponent(Context, Style)
or one of the overloads.
Then, manage its visibility with setLocationComponentEnabled(boolean)
.
The component will not process location updates right after activation, but only after being enabled.
Using this component requires you to request permission beforehand manually or using
PermissionsManager
. Either
ACCESS_COARSE_LOCATION
or ACCESS_FINE_LOCATION
permissions can be requested for
this component to work as expected.
This component offers a default, built-in LocationEngine
with some of the activation methods.
This engine will be obtained by LocationEngineProvider.getBestLocationEngine(Context, boolean)
which defaults
to the MapboxFusedLocationEngineImpl
. If you'd like to utilize Google
Play Services
for more precise location updates, simply add the Google Play Location Services dependency in your build script.
This will make the default engine the GoogleLocationEngineImpl
instead.
After a custom engine is passed to the component, or the built-in is initialized,
the location updates are going to be requested with the LocationEngineRequest
, either a default one,
or the one passed during the activation.
When using any engine, requesting/removing the location updates is going to be managed internally.
You can also push location updates to the component without any internal engine management.
To achieve that, use activateLocationComponent(Context, Style, boolean)
with false.
No engine is going to be initialized and you can push location updates with forceLocationUpdate(Location)
.
For location puck animation purposes, like navigation, we recommend limiting the maximum zoom level of the map for the best user experience.
Location Component doesn't support state saving out-of-the-box.
Constructor and Description |
---|
LocationComponent(MapboxMap mapboxMap,
Transform transform,
List<MapboxMap.OnDeveloperAnimationListener> developerAnimationListeners)
Internal use.
|
Modifier and Type | Method and Description |
---|---|
void |
activateLocationComponent(Context context,
Style style)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
boolean useDefaultLocationEngine)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
boolean useDefaultLocationEngine,
com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
boolean useDefaultLocationEngine,
com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest,
LocationComponentOptions options)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
int styleRes)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
LocationComponentOptions options)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine,
int styleRes)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine,
LocationComponentOptions options)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine,
com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine,
com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest,
int styleRes)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(Context context,
Style style,
com.mapbox.android.core.location.LocationEngine locationEngine,
com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest,
LocationComponentOptions options)
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(LocationComponentActivationOptions activationOptions)
This method initializes the component and needs to be called before any other operations are performed.
|
void |
addOnCameraTrackingChangedListener(OnCameraTrackingChangedListener listener)
Adds a listener that gets invoked when camera tracking state changes.
|
void |
addOnLocationClickListener(OnLocationClickListener listener)
Adds a listener that gets invoked when the user clicks the displayed location.
|
void |
addOnLocationLongClickListener(OnLocationLongClickListener listener)
Adds a listener that gets invoked when the user long clicks the displayed location.
|
void |
addOnLocationStaleListener(OnLocationStaleListener listener)
Adds the passed listener that gets invoked when user updates have stopped long enough for the last update
to be considered stale.
|
void |
addOnRenderModeChangedListener(OnRenderModeChangedListener listener)
Adds a listener that gets invoked when render mode changes.
|
void |
applyStyle(Context context,
int styleRes)
Apply a new component style with a style resource.
|
void |
applyStyle(LocationComponentOptions options)
Apply a new component style with location component options.
|
void |
cancelTiltWhileTrackingAnimation()
Cancels animation started by
tiltWhileTracking(double, long, MapboxMap.CancelableCallback) . |
void |
cancelZoomWhileTrackingAnimation()
Cancels animation started by
zoomWhileTracking(double, long, MapboxMap.CancelableCallback) . |
void |
forceLocationUpdate(Location location)
Use to either force a location update or to manually control when the user location gets
updated.
|
int |
getCameraMode()
Provides the current camera mode being used to track the location or compass updates.
|
CompassEngine |
getCompassEngine()
Returns the compass engine used to provide compass heading values.
|
Location |
getLastKnownLocation()
Get the last know location of the location component.
|
LocationComponentOptions |
getLocationComponentOptions()
Returns the current location options being used.
|
com.mapbox.android.core.location.LocationEngine |
getLocationEngine()
Returns the current
LocationEngine being used for updating the user location. |
com.mapbox.android.core.location.LocationEngineRequest |
getLocationEngineRequest()
Get the location request that's going to be used when requesting location updates.
|
int |
getRenderMode()
Provides the current render mode being used to show
the location and/or compass updates on the map.
|
boolean |
isLocationComponentActivated()
Returns whether the location component is activated.
|
boolean |
isLocationComponentEnabled()
Returns whether the plugin is enabled, meaning that location can be displayed and camera modes can be used.
|
void |
onDestroy()
Internal use.
|
void |
onFinishLoadingStyle()
Internal use.
|
void |
onStart()
Internal use.
|
void |
onStartLoadingMap()
Internal use.
|
void |
onStop()
Internal use.
|
void |
removeOnCameraTrackingChangedListener(OnCameraTrackingChangedListener listener)
Removes a listener that gets invoked when camera tracking state changes.
|
void |
removeOnLocationClickListener(OnLocationClickListener listener)
Removes the passed listener from the current list of location click listeners.
|
void |
removeOnLocationLongClickListener(OnLocationLongClickListener listener)
Removes the passed listener from the current list of location long click listeners.
|
void |
removeOnLocationStaleListener(OnLocationStaleListener listener)
Removes the passed listener from the current list of stale listeners.
|
void |
removeRenderModeChangedListener(OnRenderModeChangedListener listener)
Removes a listener that gets invoked when render mode changes.
|
void |
setCameraMode(int cameraMode)
Sets the camera mode, which determines how the map camera will track the rendered location.
|
void |
setCameraMode(int cameraMode,
long transitionDuration,
Double zoom,
Double bearing,
Double tilt,
OnLocationCameraTransitionListener transitionListener)
Sets the camera mode, which determines how the map camera will track the rendered location.
|
void |
setCameraMode(int cameraMode,
OnLocationCameraTransitionListener transitionListener)
Sets the camera mode, which determines how the map camera will track the rendered location.
|
void |
setCompassEngine(CompassEngine compassEngine)
Sets the compass engine used to provide compass heading values.
|
void |
setLocationComponentEnabled(boolean isEnabled)
Manage component's visibility after activation.
|
void |
setLocationEngine(com.mapbox.android.core.location.LocationEngine locationEngine)
Set the location engine to update the current user location.
|
void |
setLocationEngineRequest(com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
Set the location request that's going to be used when requesting location updates.
|
void |
setMaxAnimationFps(int maxAnimationFps)
Set max FPS at which location animators can output updates.
|
void |
setRenderMode(int renderMode)
Sets the render mode, which determines how the location updates will be rendered on the map.
|
void |
tiltWhileTracking(double tilt)
Tilts the camera.
|
void |
tiltWhileTracking(double tilt,
long animationDuration)
Tilts the camera.
|
void |
tiltWhileTracking(double tilt,
long animationDuration,
MapboxMap.CancelableCallback callback)
Tilts the camera.
|
void |
zoomWhileTracking(double zoomLevel)
Zooms to the desired zoom level.
|
void |
zoomWhileTracking(double zoomLevel,
long animationDuration)
Zooms to the desired zoom level.
|
void |
zoomWhileTracking(double zoomLevel,
long animationDuration,
MapboxMap.CancelableCallback callback)
Zooms to the desired zoom level.
|
public LocationComponent(@NonNull MapboxMap mapboxMap, @NonNull Transform transform, @NonNull List<MapboxMap.OnDeveloperAnimationListener> developerAnimationListeners)
To get the component object use MapboxMap.getLocationComponent()
.
@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.
Note: This method will initialize and use an internal LocationEngine
when enabled.
context
- the contextstyle
- the proxy object for current map style. More info at Style
@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, boolean useDefaultLocationEngine)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
useDefaultLocationEngine
- true if you want to initialize and use the built-in location engine or false if
there should be no location engine initialized@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, boolean useDefaultLocationEngine, @NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
useDefaultLocationEngine
- true if you want to initialize and use the built-in location engine or false if
there should be no location engine initializedlocationEngineRequest
- the location request@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, boolean useDefaultLocationEngine, @NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest, @NonNull LocationComponentOptions options)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
useDefaultLocationEngine
- true if you want to initialize and use the built-in location engine or false if
there should be no location engine initializedlocationEngineRequest
- the location requestoptions
- the options@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @StyleRes int styleRes)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.
Note: This method will initialize and use an internal LocationEngine
when enabled.
context
- the contextstyle
- the proxy object for current map style. More info at Style
styleRes
- the LocationComponent style res@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @NonNull LocationComponentOptions options)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.
Note: This method will initialize and use an internal LocationEngine
when enabled.
context
- the contextstyle
- the proxy object for current map style. More info at Style
options
- the options@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine, @StyleRes int styleRes)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
locationEngine
- the engine, or null if you'd like to only force location updatesstyleRes
- the LocationComponent style res@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine, @NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest, @StyleRes int styleRes)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
locationEngine
- the engine, or null if you'd like to only force location updateslocationEngineRequest
- the location requeststyleRes
- the LocationComponent style res@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine)
LocationComponentActivationOptions.Builder
insteadcontext
- the contextstyle
- the proxy object for current map style. More info at Style
locationEngine
- the engine@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine, @NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
LocationComponentActivationOptions.Builder
insteadcontext
- the contextstyle
- the proxy object for current map style. More info at Style
locationEngine
- the enginelocationEngineRequest
- the location request@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine, @NonNull LocationComponentOptions options)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.locationEngine
- the engine, or null if you'd like to only force location updatesstyle
- the proxy object for current map style. More info at Style
options
- the options@Deprecated public void activateLocationComponent(@NonNull Context context, @NonNull Style style, @Nullable com.mapbox.android.core.location.LocationEngine locationEngine, @NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest, @NonNull LocationComponentOptions options)
LocationComponentActivationOptions.Builder
insteadsetLocationComponentEnabled(boolean)
.context
- the contextstyle
- the proxy object for current map style. More info at Style
locationEngine
- the engine, or null if you'd like to only force location updateslocationEngineRequest
- the location requestoptions
- the optionspublic void activateLocationComponent(@NonNull LocationComponentActivationOptions activationOptions)
setLocationComponentEnabled(boolean)
.activationOptions
- a fully built LocationComponentActivationOptions
objectpublic void setLocationComponentEnabled(boolean isEnabled)
isEnabled
- true if the plugin should be visible and listen for location updates, false otherwise.public boolean isLocationComponentEnabled()
public void setCameraMode(int cameraMode)
When camera is transitioning to a new mode, it will reject inputs like zoomWhileTracking(double)
or
tiltWhileTracking(double)
.
Use OnLocationCameraTransitionListener
to listen for the transition state.
CameraMode.NONE
: No camera trackingCameraMode.NONE_COMPASS
: Camera does not track location, but does track compass bearingCameraMode.NONE_GPS
: Camera does not track location, but does track GPS bearingCameraMode.TRACKING
: Camera tracks the user locationCameraMode.TRACKING_COMPASS
: Camera tracks the user location, with bearing provided by a compassCameraMode.TRACKING_GPS
: Camera tracks the user location, with normalized bearingCameraMode.TRACKING_GPS_NORTH
: Camera tracks the user location, with bearing always set to northcameraMode
- one of the modes found in CameraMode
public void setCameraMode(int cameraMode, @Nullable OnLocationCameraTransitionListener transitionListener)
When camera is transitioning to a new mode, it will reject inputs like zoomWhileTracking(double)
or
tiltWhileTracking(double)
.
Use OnLocationCameraTransitionListener
to listen for the transition state.
CameraMode.NONE
: No camera trackingCameraMode.NONE_COMPASS
: Camera does not track location, but does track compass bearingCameraMode.NONE_GPS
: Camera does not track location, but does track GPS bearingCameraMode.TRACKING
: Camera tracks the user locationCameraMode.TRACKING_COMPASS
: Camera tracks the user location, with bearing provided by a compassCameraMode.TRACKING_GPS
: Camera tracks the user location, with normalized bearingCameraMode.TRACKING_GPS_NORTH
: Camera tracks the user location, with bearing always set to northcameraMode
- one of the modes found in CameraMode
transitionListener
- callback that's going to be invoked when the transition animation finishespublic void setCameraMode(int cameraMode, long transitionDuration, @Nullable Double zoom, @Nullable Double bearing, @Nullable Double tilt, @Nullable OnLocationCameraTransitionListener transitionListener)
When camera is transitioning to a new mode, it will reject inputs like zoomWhileTracking(double)
or
tiltWhileTracking(double)
.
Use OnLocationCameraTransitionListener
to listen for the transition state.
Set values of zoom, bearing and tilt that the camera will transition to. If null is passed to any of those, current value will be used for that parameter instead. If the camera is already tracking, provided values are ignored.
CameraMode.NONE
: No camera trackingCameraMode.NONE_COMPASS
: Camera does not track location, but does track compass bearingCameraMode.NONE_GPS
: Camera does not track location, but does track GPS bearingCameraMode.TRACKING
: Camera tracks the user locationCameraMode.TRACKING_COMPASS
: Camera tracks the user location, with bearing provided by a compassCameraMode.TRACKING_GPS
: Camera tracks the user location, with normalized bearingCameraMode.TRACKING_GPS_NORTH
: Camera tracks the user location, with bearing always set to northcameraMode
- one of the modes found in CameraMode
transitionDuration
- duration of the transition in millisecondszoom
- target zoom, set to null to use current camera positionbearing
- target bearing, set to null to use current camera positiontilt
- target tilt, set to null to use current camera positiontransitionListener
- callback that's going to be invoked when the transition animation finishespublic int getCameraMode()
public void setRenderMode(int renderMode)
RenderMode.NORMAL
: Shows user location, bearing ignoredRenderMode.COMPASS
: Shows user location with bearing considered from compassRenderMode.GPS
: Shows user location with bearing considered from locationrenderMode
- one of the modes found in RenderMode
public int getRenderMode()
public LocationComponentOptions getLocationComponentOptions()
LocationComponentOptions
public void applyStyle(@NonNull Context context, @StyleRes int styleRes)
styleRes
- a XML style overriding some or all the optionspublic void applyStyle(@NonNull LocationComponentOptions options)
options
- to update the current stylepublic void zoomWhileTracking(double zoomLevel, long animationDuration, @Nullable MapboxMap.CancelableCallback callback)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.zoomLevel
- The desired zoom level.animationDuration
- The zoom animation duration.callback
- The callback with finish/cancel informationpublic void zoomWhileTracking(double zoomLevel, long animationDuration)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.zoomLevel
- The desired zoom level.animationDuration
- The zoom animation duration.public void zoomWhileTracking(double zoomLevel)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.zoomLevel
- The desired zoom level.public void cancelZoomWhileTrackingAnimation()
zoomWhileTracking(double, long, MapboxMap.CancelableCallback)
.public void tiltWhileTracking(double tilt, long animationDuration, @Nullable MapboxMap.CancelableCallback callback)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.tilt
- The desired camera tilt.animationDuration
- The tilt animation duration.callback
- The callback with finish/cancel informationpublic void tiltWhileTracking(double tilt, long animationDuration)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.tilt
- The desired camera tilt.animationDuration
- The tilt animation duration.public void tiltWhileTracking(double tilt)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of MapboxMap.moveCamera(CameraUpdate)
,
MapboxMap.easeCamera(CameraUpdate)
or MapboxMap.animateCamera(CameraUpdate)
instead.tilt
- The desired camera tilt.public void cancelTiltWhileTrackingAnimation()
tiltWhileTracking(double, long, MapboxMap.CancelableCallback)
.public void forceLocationUpdate(@Nullable Location location)
location
- where the location icon is placed on the mappublic void setMaxAnimationFps(int maxAnimationFps)
Setting this will not impact any other animations schedule with MapboxMap
, gesture animations or
zoomWhileTracking(double)
/tiltWhileTracking(double)
.
Use this setting to limit animation rate of the location puck on higher zoom levels to decrease the stress on the device's CPU which can directly improve battery life, without sacrificing UX.
Example usage:
mapboxMap.addOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
{@literal @}Override
public void onCameraIdle() {
double zoom = mapboxMap.getCameraPosition().zoom;
int maxAnimationFps;
if (zoom < 5) {
maxAnimationFps = 3;
} else if (zoom < 10) {
maxAnimationFps = 5;
} else if (zoom < 15) {
maxAnimationFps = 7;
} else if (zoom < 18) {
maxAnimationFps = 15;
} else {
maxAnimationFps = Integer.MAX_VALUE;
}
locationComponent.setMaxAnimationFps(maxAnimationFps);
}
});
If you're looking for a way to throttle the FPS of the whole map, including other animations and gestures, see
MapView.setMaximumFps(int)
.
maxAnimationFps
- max location animation FPSpublic void setLocationEngine(@Nullable com.mapbox.android.core.location.LocationEngine locationEngine)
If null
is passed in, all updates will have to occur through the
forceLocationUpdate(Location)
method.
locationEngine
- a LocationEngine
this component should use to handle updatespublic void setLocationEngineRequest(@NonNull com.mapbox.android.core.location.LocationEngineRequest locationEngineRequest)
locationEngineRequest
- the location request@NonNull public com.mapbox.android.core.location.LocationEngineRequest getLocationEngineRequest()
@Nullable public com.mapbox.android.core.location.LocationEngine getLocationEngine()
LocationEngine
being used for updating the user location.LocationEngine
being used to update the user locationpublic void setCompassEngine(@Nullable CompassEngine compassEngine)
compassEngine
- to be used@Nullable public CompassEngine getCompassEngine()
@Nullable public Location getLastKnownLocation()
public void addOnLocationClickListener(@NonNull OnLocationClickListener listener)
If there are registered location click listeners and the location is clicked,
only OnLocationClickListener.onLocationComponentClick()
is going to be delivered,
MapboxMap.OnMapClickListener.onMapClick(LatLng)
is going to be consumed
and not pushed to the listeners registered after the component's activation.
listener
- The location click listener that is invoked when the
location is clickedpublic void removeOnLocationClickListener(@NonNull OnLocationClickListener listener)
listener
- to be removedpublic void addOnLocationLongClickListener(@NonNull OnLocationLongClickListener listener)
If there are registered location long click listeners and the location is long clicked,
only OnLocationLongClickListener.onLocationComponentLongClick()
is going to be delivered,
MapboxMap.OnMapLongClickListener.onMapLongClick(LatLng)
is going to be consumed
and not pushed to the listeners registered after the component's activation.
listener
- The location click listener that is invoked when the
location is clickedpublic void removeOnLocationLongClickListener(@NonNull OnLocationLongClickListener listener)
listener
- to be removedpublic void addOnCameraTrackingChangedListener(@NonNull OnCameraTrackingChangedListener listener)
listener
- Listener that gets invoked when camera tracking state changes.public void removeOnCameraTrackingChangedListener(@NonNull OnCameraTrackingChangedListener listener)
listener
- Listener that gets invoked when camera tracking state changes.public void addOnRenderModeChangedListener(@NonNull OnRenderModeChangedListener listener)
listener
- Listener that gets invoked when render mode changes.public void removeRenderModeChangedListener(@NonNull OnRenderModeChangedListener listener)
listener
- Listener that gets invoked when render mode changes.public void addOnLocationStaleListener(@NonNull OnLocationStaleListener listener)
This timeout is set by LocationComponentOptions.staleStateTimeout()
.
listener
- invoked when last update is considered stalepublic void removeOnLocationStaleListener(@NonNull OnLocationStaleListener listener)
listener
- to be removed from the listpublic void onStart()
public void onStop()
public void onDestroy()
public void onStartLoadingMap()
public void onFinishLoadingStyle()
public boolean isLocationComponentActivated()
© 2015–2019 Mapbox. All rights reserved.