Class NavigationTrimbleMapsMap
-
- All Implemented Interfaces:
-
androidx.lifecycle.LifecycleObserver
@UiThread() public class NavigationTrimbleMapsMap implements LifecycleObserver
Wrapper class for TrimbleMapsMap.
This class initializes various map-related components and plugins that are useful for providing a navigation-driven map experience.
These APIs include drawing a route line, camera animations, and more.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classNavigationTrimbleMapsMap.BuilderCreates NavigationTrimbleMapsMap object.
-
Field Summary
Fields Modifier and Type Field Description public final static StringTRIMBLEMAPS_NAVIGATION_FEEDBACK_MARKER_NAME
-
Method Summary
Modifier and Type Method Description voidaddDestinationMarker(Point position)Adds a marker icon on the map at the given position. SymboladdCustomMarker(SymbolOptions options)Adds a custom marker to the map based on the options provided. voidclearMarkerWithId(long markerId)Clears marker with the specified marker id. voidclearMarkersWithIconImageProperty(String markerIconImageProperty)Clears all markers with the specified icon image. voidclearMarkers()Clears all markers on the map that have been added by this class. voidupdateLocation(@Nullable() Location location)Updates the location icon on the map and way name data (if found) for the given Location. voidupdateLocation(@Nullable() Location location, @Nullable() Long animationDuration)Updates the location icon on the map and way name data (if found) for the given Location. voidupdateLocation(@NonNull() List<Location> locations)This method can be used to provide the list of locations where the last one is the target and the rest are intermediate points used as the animation path. voidupdateLocation(@NonNull() List<Location> locations, @Nullable() Long animationDuration)This method can be used to provide the list of locations where the last one is the target and the rest are intermediate points used as the animation path. voidupdateLocation(@NonNull() Location location, @NonNull() List<Location> intermediateLocations, @Nullable() Long animationDuration)This method can be used to provide the target location and a list of intermediate points used as the animation path. voidupdateMapFpsThrottle(int maxFpsThreshold)The maximum preferred frames per second at which to render the map. voidupdateMapFpsThrottleEnabled(boolean isEnabled)Enabled by default, the navigation map will throttle frames per second when the application has limited resources, such as when the device is running on battery power. voidupdateLocationFpsThrottleEnabled(boolean isEnabled)Enabled by default, the navigation map will throttle frames per second of the location icon based on the map zoom level. voidupdateLocationLayerRenderMode(int renderMode)Updates how the user location is shown on the map. voidaddProgressChangeListener(@NonNull() TrimbleMapsNavigation navigation)Can be used to automatically drive the map camera, puck and route updates when STARTED. voidremoveProgressChangeListener()Removes the previously registered progress change listener. voidsaveStateWith(@NonNull() Bundle outState)Can be used to store the current state of the map in onSaveInstanceState. voidrestoreStateFrom(@NonNull() Bundle inState)Can be used to restore a NavigationTrimbleMapsMap after it has been initialized. voiddrawRoute(@NonNull() DirectionsRoute route)Will draw the given DirectionsRoute on the map using the colors defined in your given style. voidclearRoute()voiddrawRoutes(@NonNull() List<out DirectionsRoute> routes, TrimbleMapsTrip trimbleMapsTrip, int stopNumberOffset)Will draw the given list of DirectionsRoute on the map using the colors defined in your given style. voiddrawIdentifiableRoute(@NonNull() IdentifiableRoute route)voiddrawIdentifiableRoutes(@NonNull() List<IdentifiableRoute> routes)voidonNewRouteProgress(RouteProgress routeProgress)Can be used to manually update the route progress. voidsetOnRouteSelectionChangeListener(@NonNull() OnRouteSelectionChangeListener listener)Set a OnRouteSelectionChangeListener to know which route the user has currently selected as their primary route. voidshowAlternativeRoutes(boolean alternativesVisible)Toggle whether or not you'd like the map to display the alternative routes. voidhideRoute()Will hide the drawn route displayed on the map. voidshowRoute()Will show the drawn route displayed on the map. NavigationCameraretrieveCamera()Provides the camera being used to animate the map camera positions along the route, driven by the progress change listener. NavigationMapRouteretrieveMapRoute()Provides the object being used to draw the route line. voidupdateCameraTrackingMode(int trackingMode)Updates the NavigationCamera.TrackingMode that will be used when camera tracking is enabled. voidstartCamera(@NonNull() DirectionsRoute directionsRoute)Centers the map camera to the beginning of the provided DirectionsRoute. voidresumeCamera(@NonNull() Location location)Centers the map camera around the provided Location. voidresetCameraPositionWith(int trackingCameraMode)Resets the map camera / padding to the last known camera position. voidresetPadding()This method resets the map padding to the default padding that is generated when navigation begins (location icon moved to lower half of the screen) or the custom padding that was last passed via adjustLocationIconWith. booleanshowRouteGeometryOverview(Array<int> padding)Adjusts the map camera to DirectionsRoute being traveled along. voidupdateWaynameQueryMap(boolean isEnabled)Enables or disables the way name chip underneath the location icon. voidupdateLocationVisibilityTo(boolean isVisible)Hide or show the location icon on the map. TrimbleMapsMapretrieveMap()Provides the TrimbleMapsMap originally given in the constructor. voidupdateTrafficVisibility(boolean isVisible)Updates the visibility of traffic layers on the map (if any exist). voidupdateTruckRestrictionsVisibility(boolean isVisible)Updates the visibility of truck restrictions layers on the map (if any exist). booleanisTrafficVisible()Returns true if the map has traffic layers and they are visible and will return false otherwise. booleanisTruckRestrictionsVisible()Returns true if the map has truck restrictions layers and they are visible and will return false otherwise. voidaddOnCameraTrackingChangedListener(@NonNull() OnCameraTrackingChangedListener listener)Add a OnCameraTrackingChangedListener to the LocationComponent that is wrapped within this class. voidremoveOnCameraTrackingChangedListener(@NonNull() OnCameraTrackingChangedListener listener)Remove a OnCameraTrackingChangedListener from the LocationComponent that is wrapped within this class. booleanaddOnWayNameChangedListener(OnWayNameChangedListener listener)Add a OnWayNameChangedListener for listening to updates to the way name shown on the map below the location icon. booleanremoveOnWayNameChangedListener(OnWayNameChangedListener listener)Remove a OnWayNameChangedListener for listening to updates to the way name shown on the map below the location icon. voidadjustLocationIconWith(@NonNull() Array<int> customPadding)Use this method to position the location icon on the map. voidsetCamera(Camera camera)Set Camera which allows you to perform operations like zoom, tilt etc. voidsetArriving(boolean arriving)voidsetPuckDrawableSupplier(@NonNull() PuckDrawableSupplier supplier)Allows to pass in a custom implementation of PuckDrawableSupplier voidtakeScreenshot(@NonNull() TrimbleMapsMap.SnapshotReadyCallback snapshotReadyCallback)Used to take the snapshot of the current state of the map. voidenableVanishingRouteLine()This will enable the feature to change the appearance of the route line behind the puck as it moves across the map. voiddisableVanishingRouteLine()This will disable the feature to change the appearance of the route line behind the puck as it moves across the map. voidenableDrawingOnboardMapData()voiddisableDrawingOnboardMapData()voidinitializeStreetsSource(@NonNull() TrimbleMapsMap tmMap)
-
-
-
Method Detail
-
addDestinationMarker
void addDestinationMarker(Point position)
Adds a marker icon on the map at the given position.
The icon used for this method can be defined in your theme with the attribute navigationViewDestinationMarker.
- Parameters:
position- the point at which the marker will be placed
-
addCustomMarker
Symbol addCustomMarker(SymbolOptions options)
Adds a custom marker to the map based on the options provided.
Please note, the map will manage all markers added. Calling clearMarkers will clear all destination / custom markers that have been added to the map.
- Parameters:
options- for the custom com.trimblemaps.mapsdk.plugins.annotation.Symbol
-
clearMarkerWithId
void clearMarkerWithId(long markerId)
Clears marker with the specified marker id.
Please note, this only clears the marker added by addCustomMarker
- Parameters:
markerId- of the com.trimblemaps.mapsdk.plugins.annotation.Symbol
-
clearMarkersWithIconImageProperty
void clearMarkersWithIconImageProperty(String markerIconImageProperty)
Clears all markers with the specified icon image.
Please note, this only clears the markers added by addCustomMarker
- Parameters:
markerIconImageProperty- of the com.trimblemaps.mapsdk.plugins.annotation.Symbol
-
clearMarkers
void clearMarkers()
Clears all markers on the map that have been added by this class.
This will not clear all markers from the map entirely. Does nothing if no markers have been added.
-
updateLocation
void updateLocation(@Nullable() Location location)
Updates the location icon on the map and way name data (if found) for the given Location.
NavigationTrimbleMapsMap automatically listens to onNewMapMatcherResult when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
location- to update the icon and query the map
-
updateLocation
void updateLocation(@Nullable() Location location, @Nullable() Long animationDuration)
Updates the location icon on the map and way name data (if found) for the given Location.
NavigationTrimbleMapsMap automatically listens to onNewMapMatcherResult when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
location- to update the icon and query the mapanimationDuration- specifies the duration of the transition animation.
-
updateLocation
void updateLocation(@NonNull() List<Location> locations)
This method can be used to provide the list of locations where the last one is the target 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.
NavigationTrimbleMapsMap automatically listens to onNewMapMatcherResult when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
locations- the path to update the location icon
-
updateLocation
void updateLocation(@NonNull() List<Location> locations, @Nullable() Long animationDuration)
This method can be used to provide the list of locations where the last one is the target 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.
NavigationTrimbleMapsMap automatically listens to onNewMapMatcherResult when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
locations- the path to update the location iconanimationDuration- specifies the duration of the transition animation.
-
updateLocation
void updateLocation(@NonNull() Location location, @NonNull() List<Location> intermediateLocations, @Nullable() Long animationDuration)
This method can be used to provide the target location and a list of 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.
NavigationTrimbleMapsMap automatically listens to onNewMapMatcherResult when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
location- the target positionintermediateLocations- points that lead up to the target position for animation purposesanimationDuration- specifies the duration of the transition animation.
-
updateMapFpsThrottle
void updateMapFpsThrottle(int maxFpsThreshold)
The maximum preferred frames per second at which to render the map.
This property only takes effect when the application has limited resources, such as when the device is running on battery power. By default, this is set to 20fps.
Throttling will also only take effect when the camera is currently tracking the user location.
- Parameters:
maxFpsThreshold- to be used to limit map frames per second
-
updateMapFpsThrottleEnabled
void updateMapFpsThrottleEnabled(boolean isEnabled)
Enabled by default, the navigation map will throttle frames per second when the application has limited resources, such as when the device is running on battery power.
Throttling will also only take effect when the camera is currently tracking the user location.
- Parameters:
isEnabled- true to enable (default), false to render at device ability
-
updateLocationFpsThrottleEnabled
void updateLocationFpsThrottleEnabled(boolean isEnabled)
Enabled by default, the navigation map will throttle frames per second of the location icon based on the map zoom level.
- Parameters:
isEnabled- true to enable (default), false to render at device ability
-
updateLocationLayerRenderMode
void updateLocationLayerRenderMode(int renderMode)
Updates how the user location is shown on the map.
- NORMAL: Shows user location, bearing ignored
- COMPASS: Shows user location with bearing considered from compass
- GPS: Shows user location with bearing considered from location
- Parameters:
renderMode- GPS, NORMAL, or COMPASS
-
addProgressChangeListener
void addProgressChangeListener(@NonNull() TrimbleMapsNavigation navigation)
Can be used to automatically drive the map camera, puck and route updates when STARTED.
Use removeProgressChangeListener when the session is finished to avoid leaks.
- Parameters:
navigation- to add the progress listeners
-
removeProgressChangeListener
void removeProgressChangeListener()
Removes the previously registered progress change listener.
-
saveStateWith
void saveStateWith(@NonNull() Bundle outState)
Can be used to store the current state of the map in onSaveInstanceState.
- Parameters:
outState- to store state variables
-
restoreStateFrom
void restoreStateFrom(@NonNull() Bundle inState)
Can be used to restore a NavigationTrimbleMapsMap after it has been initialized.
This cannot be called in onViewStateRestored because we cannot guarantee the map is re-initialized at that point.
- Parameters:
inState- to store state variables
-
drawRoute
void drawRoute(@NonNull() DirectionsRoute route)
Will draw the given DirectionsRoute on the map using the colors defined in your given style.
In most of the scenarios, this call can be wired to the onRoutesChanged to display the route that TrimbleMapsNavigation uses to compute the route progress.
- Parameters:
route- to be drawn
-
clearRoute
void clearRoute()
-
drawRoutes
void drawRoutes(@NonNull() List<out DirectionsRoute> routes, TrimbleMapsTrip trimbleMapsTrip, int stopNumberOffset)
Will draw the given list of DirectionsRoute on the map using the colors defined in your given style.
The primary route will default to the first route in the directions route list. All other routes in the list will be drawn on the map using the alternative route style.
In most of the scenarios, this call can be wired to the onRoutesChanged to display the route that TrimbleMapsNavigation uses to compute the route progress.
- Parameters:
routes- to be drawn
-
drawIdentifiableRoute
void drawIdentifiableRoute(@NonNull() IdentifiableRoute route)
-
drawIdentifiableRoutes
void drawIdentifiableRoutes(@NonNull() List<IdentifiableRoute> routes)
-
onNewRouteProgress
void onNewRouteProgress(RouteProgress routeProgress)
Can be used to manually update the route progress.
NavigationTrimbleMapsMap automatically listens to onRouteProgressChanged when a progress observer is subscribed with addProgressChangeListener and invoking this method in that scenario will lead to competing updates.
- Parameters:
routeProgress- current progress
-
setOnRouteSelectionChangeListener
void setOnRouteSelectionChangeListener(@NonNull() OnRouteSelectionChangeListener listener)
Set a OnRouteSelectionChangeListener to know which route the user has currently selected as their primary route.
- Parameters:
listener- a listener which lets you know when the user has changed the primary route and provides the current direction route which the user has selected
-
showAlternativeRoutes
void showAlternativeRoutes(boolean alternativesVisible)
Toggle whether or not you'd like the map to display the alternative routes. This option can be used for when the user actually begins the navigation session and alternative routes aren't needed anymore.
- Parameters:
alternativesVisible- true if you'd like alternative routes to be displayed on the map, else false
-
hideRoute
void hideRoute()
Will hide the drawn route displayed on the map. Does nothing if no route is drawn.
-
showRoute
void showRoute()
Will show the drawn route displayed on the map.
-
retrieveCamera
NavigationCamera retrieveCamera()
Provides the camera being used to animate the map camera positions along the route, driven by the progress change listener.
-
retrieveMapRoute
NavigationMapRoute retrieveMapRoute()
Provides the object being used to draw the route line.
-
updateCameraTrackingMode
void updateCameraTrackingMode(int trackingMode)
Updates the NavigationCamera.TrackingMode that will be used when camera tracking is enabled.
- Parameters:
trackingMode- the tracking mode
-
startCamera
void startCamera(@NonNull() DirectionsRoute directionsRoute)
Centers the map camera to the beginning of the provided DirectionsRoute.
- Parameters:
directionsRoute- to update the camera position
-
resumeCamera
void resumeCamera(@NonNull() Location location)
Centers the map camera around the provided Location.
- Parameters:
location- to update the camera position
-
resetCameraPositionWith
void resetCameraPositionWith(int trackingCameraMode)
Resets the map camera / padding to the last known camera position.
You can also specify a tracking mode to reset with. For example if you would like to reset the camera and continue tracking, you would use NAVIGATION_TRACKING_MODE_GPS.
- Parameters:
trackingCameraMode- the tracking mode
-
resetPadding
void resetPadding()
This method resets the map padding to the default padding that is generated when navigation begins (location icon moved to lower half of the screen) or the custom padding that was last passed via adjustLocationIconWith.
The custom padding will be used if it exists, otherwise the default will be used.
-
showRouteGeometryOverview
boolean showRouteGeometryOverview(Array<int> padding)
Adjusts the map camera to DirectionsRoute being traveled along.
Also includes the given padding.
- Parameters:
padding- for creating the overview camera position
-
updateWaynameQueryMap
void updateWaynameQueryMap(boolean isEnabled)
Enables or disables the way name chip underneath the location icon.
- Parameters:
isEnabled- true to enable, false to disable
-
updateLocationVisibilityTo
void updateLocationVisibilityTo(boolean isVisible)
Hide or show the location icon on the map.
- Parameters:
isVisible- true to show, false to hide
-
retrieveMap
@NonNull() TrimbleMapsMap retrieveMap()
Provides the TrimbleMapsMap originally given in the constructor.
This method gives access to all map-related APIs.
-
updateTrafficVisibility
void updateTrafficVisibility(boolean isVisible)
Updates the visibility of traffic layers on the map (if any exist).
- Parameters:
isVisible- true if traffic should be visible, false otherwise
-
updateTruckRestrictionsVisibility
void updateTruckRestrictionsVisibility(boolean isVisible)
Updates the visibility of truck restrictions layers on the map (if any exist).
- Parameters:
isVisible- true if restrictions should be visible, false otherwise
-
isTrafficVisible
boolean isTrafficVisible()
Returns true if the map has traffic layers and they are visible and will return false otherwise.
-
isTruckRestrictionsVisible
boolean isTruckRestrictionsVisible()
Returns true if the map has truck restrictions layers and they are visible and will return false otherwise.
-
addOnCameraTrackingChangedListener
void addOnCameraTrackingChangedListener(@NonNull() OnCameraTrackingChangedListener listener)
Add a OnCameraTrackingChangedListener to the LocationComponent that is wrapped within this class.
This listener will fire any time camera tracking is dismissed or the camera mode is updated.
- Parameters:
listener- to be added
-
removeOnCameraTrackingChangedListener
void removeOnCameraTrackingChangedListener(@NonNull() OnCameraTrackingChangedListener listener)
Remove a OnCameraTrackingChangedListener from the LocationComponent that is wrapped within this class.
- Parameters:
listener- to be removed
-
addOnWayNameChangedListener
boolean addOnWayNameChangedListener(OnWayNameChangedListener listener)
Add a OnWayNameChangedListener for listening to updates to the way name shown on the map below the location icon.
- Parameters:
listener- to be added
-
removeOnWayNameChangedListener
boolean removeOnWayNameChangedListener(OnWayNameChangedListener listener)
Remove a OnWayNameChangedListener for listening to updates to the way name shown on the map below the location icon.
- Parameters:
listener- to be removed
-
adjustLocationIconWith
void adjustLocationIconWith(@NonNull() Array<int> customPadding)
Use this method to position the location icon on the map.
For example, to position the icon in the center of the map, you can pass {0, 0, 0, 0} which eliminates the default padding we provide when navigation begins.
- Parameters:
customPadding- true if should be centered on the map, false to position above the bottom view
-
setCamera
void setCamera(Camera camera)
Set Camera which allows you to perform operations like zoom, tilt etc.
- Parameters:
camera- Camera
-
setArriving
void setArriving(boolean arriving)
-
setPuckDrawableSupplier
void setPuckDrawableSupplier(@NonNull() PuckDrawableSupplier supplier)
Allows to pass in a custom implementation of PuckDrawableSupplier
- Parameters:
supplier- PuckDrawableSupplier
-
takeScreenshot
void takeScreenshot(@NonNull() TrimbleMapsMap.SnapshotReadyCallback snapshotReadyCallback)
Used to take the snapshot of the current state of the map.
-
enableVanishingRouteLine
void enableVanishingRouteLine()
This will enable the feature to change the appearance of the route line behind the puck as it moves across the map.
-
disableVanishingRouteLine
void disableVanishingRouteLine()
This will disable the feature to change the appearance of the route line behind the puck as it moves across the map.
-
enableDrawingOnboardMapData
void enableDrawingOnboardMapData()
-
disableDrawingOnboardMapData
void disableDrawingOnboardMapData()
-
initializeStreetsSource
void initializeStreetsSource(@NonNull() TrimbleMapsMap tmMap)
-
-