public final class LocationComponent
extends java.lang.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 TrimbleMapsMap.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 TrimbleMapsFusedLocationEngineImpl
. 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 | Description |
---|---|
LocationComponent(TrimbleMapsMap trimbleMapsMap,
Transform transform,
java.util.List<TrimbleMapsMap.OnDeveloperAnimationListener> developerAnimationListeners) |
Internal use.
|
Modifier and Type | Method | Description |
---|---|---|
void |
activateLocationComponent(android.content.Context context,
Style style) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
boolean useDefaultLocationEngine) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
boolean useDefaultLocationEngine,
com.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
boolean useDefaultLocationEngine,
com.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest,
LocationComponentOptions options) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
int styleRes) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine,
int styleRes) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine,
com.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine,
com.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest,
int styleRes) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine,
com.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest,
LocationComponentOptions options) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
com.trimblemaps.android.core.location.LocationEngine locationEngine,
LocationComponentOptions options) |
Deprecated.
use
LocationComponentActivationOptions.Builder instead |
void |
activateLocationComponent(android.content.Context context,
Style style,
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 |
addOnIndicatorPositionChangedListener(OnIndicatorPositionChangedListener listener) |
Adds a listener that gets invoked when indicator position 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(android.content.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 |
cancelPaddingWhileTrackingAnimation() |
Cancels animation started by
paddingWhileTracking(double[], long, TrimbleMapsMap.CancelableCallback) . |
void |
cancelTiltWhileTrackingAnimation() |
Cancels animation started by
tiltWhileTracking(double, long, TrimbleMapsMap.CancelableCallback) . |
void |
cancelZoomWhileTrackingAnimation() |
Cancels animation started by
zoomWhileTracking(double, long, TrimbleMapsMap.CancelableCallback) . |
void |
forceLocationUpdate(android.location.Location location) |
Deprecated.
use
forceLocationUpdate(LocationUpdate) instead |
void |
forceLocationUpdate(LocationUpdate locationUpdate) |
Use to either force a location update or to manually control when the user location gets
updated.
|
void |
forceLocationUpdate(java.util.List<android.location.Location> locations,
boolean lookAheadUpdate) |
Deprecated.
use
forceLocationUpdate(LocationUpdate) instead |
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.
|
android.location.Location |
getLastKnownLocation() |
Get the last know location of the location component.
|
LocationComponentOptions |
getLocationComponentOptions() |
Returns the current location options being used.
|
com.trimblemaps.android.core.location.LocationEngine |
getLocationEngine() |
Returns the current
LocationEngine being used for updating the user location. |
com.trimblemaps.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 |
paddingWhileTracking(double[] padding) |
Sets the padding.
|
void |
paddingWhileTracking(double[] padding,
long animationDuration) |
Sets the padding.
|
void |
paddingWhileTracking(double[] padding,
long animationDuration,
TrimbleMapsMap.CancelableCallback callback) |
Sets the padding.
|
void |
removeOnCameraTrackingChangedListener(OnCameraTrackingChangedListener listener) |
Removes a listener that gets invoked when camera tracking state changes.
|
void |
removeOnIndicatorPositionChangedListener(OnIndicatorPositionChangedListener listener) |
Removes a listener that gets invoked when indicator position 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,
java.lang.Double zoom,
java.lang.Double bearing,
java.lang.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.trimblemaps.android.core.location.LocationEngine locationEngine) |
Set the location engine to update the current user location.
|
void |
setLocationEngineRequest(com.trimblemaps.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,
TrimbleMapsMap.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,
TrimbleMapsMap.CancelableCallback callback) |
Zooms to the desired zoom level.
|
public LocationComponent(@NonNull TrimbleMapsMap trimbleMapsMap, @NonNull Transform transform, @NonNull java.util.List<TrimbleMapsMap.OnDeveloperAnimationListener> developerAnimationListeners)
To get the component object use TrimbleMapsMap.getLocationComponent()
.
@Deprecated public void activateLocationComponent(@NonNull android.content.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 android.content.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 android.content.Context context, @NonNull Style style, boolean useDefaultLocationEngine, @NonNull com.trimblemaps.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 android.content.Context context, @NonNull Style style, boolean useDefaultLocationEngine, @NonNull com.trimblemaps.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 android.content.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 android.content.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.android.core.location.LocationEngine locationEngine, @NonNull com.trimblemaps.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.android.core.location.LocationEngine locationEngine, @NonNull com.trimblemaps.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.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 android.content.Context context, @NonNull Style style, @Nullable com.trimblemaps.android.core.location.LocationEngine locationEngine, @NonNull com.trimblemaps.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 java.lang.Double zoom, @Nullable java.lang.Double bearing, @Nullable java.lang.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 android.content.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 TrimbleMapsMap.CancelableCallback callback)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the zoom as a camera change argument.
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 TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the zoom as a camera change argument.
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 TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the zoom change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the zoom as a camera change argument.
zoomLevel
- The desired zoom level.public void cancelZoomWhileTrackingAnimation()
zoomWhileTracking(double, long, TrimbleMapsMap.CancelableCallback)
.public void paddingWhileTracking(double[] padding)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the padding change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the padding as a camera change argument.
padding
- The desired padding.public void paddingWhileTracking(double[] padding, long animationDuration)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the padding change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the padding as a camera change argument.
padding
- The desired padding.animationDuration
- The padding animation duration.public void paddingWhileTracking(double[] padding, long animationDuration, @Nullable TrimbleMapsMap.CancelableCallback callback)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the padding change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the padding as a camera change argument.
padding
- The desired padding.animationDuration
- The padding animation duration.callback
- The callback with finish/cancel informationpublic void cancelPaddingWhileTrackingAnimation()
paddingWhileTracking(double[], long, TrimbleMapsMap.CancelableCallback)
.public void tiltWhileTracking(double tilt, long animationDuration, @Nullable TrimbleMapsMap.CancelableCallback callback)
CameraMode.NONE
.
If you are not using any of CameraMode
modes,
use one of TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the tilt as a camera change argument.
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 TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the tilt as a camera change argument.
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 TrimbleMapsMap.moveCamera(CameraUpdate)
,
TrimbleMapsMap.easeCamera(CameraUpdate)
or TrimbleMapsMap.animateCamera(CameraUpdate)
instead.
If the camera is transitioning when the tilt change is requested, the call is going to be ignored.
Use LocationComponent.CameraTransitionListener
to chain the animations, or provide the tilt as a camera change argument.
tilt
- The desired camera tilt.public void cancelTiltWhileTrackingAnimation()
tiltWhileTracking(double, long, TrimbleMapsMap.CancelableCallback)
.@Deprecated public void forceLocationUpdate(@Nullable android.location.Location location)
forceLocationUpdate(LocationUpdate)
insteadlocation
- where the location icon is placed on the map@Deprecated public void forceLocationUpdate(@Nullable java.util.List<android.location.Location> locations, boolean lookAheadUpdate)
forceLocationUpdate(LocationUpdate)
insteadThis method can be used to provide the list of locations where the last one is the target location and the rest are intermediate points used as the animation path. The puck and the camera will be animated between each of the points linearly until reaching the target.
locations
- where the location icon is placed on the maplookAheadUpdate
- If set to true, the last location's timestamp has to be greater than current timestamp and
should represent the time at which the animation should actually reach this position,
cutting out the time interpolation delay.public void forceLocationUpdate(@NonNull LocationUpdate locationUpdate)
locationUpdate
- location updateLocationUpdate.Builder
public void setMaxAnimationFps(int maxAnimationFps)
Setting this will not impact any other animations schedule with TrimbleMapsMap
, 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:
trimbleMapsMap.addOnCameraIdleListener(new TrimbleMapsMap.OnCameraIdleListener() {
{@literal @}Override
public void onCameraIdle() {
double zoom = trimbleMapsMap.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.trimblemaps.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.trimblemaps.android.core.location.LocationEngineRequest locationEngineRequest)
locationEngineRequest
- the location request@NonNull public com.trimblemaps.android.core.location.LocationEngineRequest getLocationEngineRequest()
@Nullable public com.trimblemaps.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 android.location.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,
TrimbleMapsMap.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,
TrimbleMapsMap.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 addOnIndicatorPositionChangedListener(@NonNull OnIndicatorPositionChangedListener listener)
listener
- Listener that gets invoked when indicator position changespublic void removeOnIndicatorPositionChangedListener(@NonNull OnIndicatorPositionChangedListener listener)
listener
- Listener that gets invoked when indicator position changes.public void onStart()
public void onStop()
public void onDestroy()
public void onStartLoadingMap()
public void onFinishLoadingStyle()
public boolean isLocationComponentActivated()