Class TrimbleMapsMap

java.lang.Object
com.trimblemaps.mapsdk.maps.TrimbleMapsMap

@UiThread public final class TrimbleMapsMap extends Object
The general class to interact with in the Android TrimbleMaps SDK. It exposes the entry point for all methods related to the MapView. You cannot instantiate TrimbleMapsMap object directly, rather, you must obtain one from the getMapAsync() method on a MapFragment or MapView that you have added to your application.

Note: Similar to a View object, a TrimbleMapsMap should only be read and modified from the main thread.

  • Method Details

    • triggerRepaint

      public void triggerRepaint()
      Trigger the mapview to repaint.
    • setSwapBehaviorFlush

      public void setSwapBehaviorFlush(boolean flush)
    • getStyle

      public void getStyle(@NonNull Style.OnStyleLoaded onStyleLoaded)
      Get the Style of the map asynchronously.
    • getStyle

      @Nullable public Style getStyle()
      Get the Style of the map.

      Returns null when style is being loaded.

      Returns:
      the style of the map
    • setPrefetchesTiles

      @Deprecated public void setPrefetchesTiles(boolean enable)
      Deprecated.
      Enable or disable tile pre-fetching. Pre-fetching makes sure that a low-resolution tile is rendered as soon as possible at the expense of a little bandwidth.
      Parameters:
      enable - true to enable
    • getPrefetchesTiles

      @Deprecated public boolean getPrefetchesTiles()
      Deprecated.
      Check whether tile pre-fetching is enabled or not.
      Returns:
      true if enabled
      See Also:
    • setPrefetchZoomDelta

      public void setPrefetchZoomDelta(@IntRange(from=0L) int delta)
      Set the tile pre-fetching zoom delta. Pre-fetching makes sure that a low-resolution tile at the (current_zoom_level - delta) is rendered as soon as possible at the expense of a little bandwidth. Note: This operation will override the TrimbleMapsMapOptions#setPrefetchesTiles(boolean) Setting zoom delta to 0 will disable pre-fetching. Default zoom delta is 4.
      Parameters:
      delta - zoom delta
    • getPrefetchZoomDelta

      @IntRange(from=0L) public int getPrefetchZoomDelta()
      Check current pre-fetching zoom delta.
      Returns:
      current zoom delta.
      See Also:
    • setMinZoomPreference

      public void setMinZoomPreference(@FloatRange(from=0.0,to=25.5) double minZoom)

      Sets the minimum zoom level the map can be displayed at.

      Parameters:
      minZoom - The new minimum zoom level.
    • getMinZoomLevel

      public double getMinZoomLevel()

      Gets the minimum zoom level the map can be displayed at.

      Returns:
      The minimum zoom level.
    • setMaxZoomPreference

      public void setMaxZoomPreference(@FloatRange(from=0.0,to=25.5) double maxZoom)

      Sets the maximum zoom level the map can be displayed at.

      The default maximum zoomn level is 22. The upper bound for this value is 25.5.

      Parameters:
      maxZoom - The new maximum zoom level.
    • getMaxZoomLevel

      public double getMaxZoomLevel()

      Gets the maximum zoom level the map can be displayed at.

      Returns:
      The maximum zoom level.
    • setMinPitchPreference

      public void setMinPitchPreference(@FloatRange(from=0.0,to=60.0) double minPitch)

      Sets the minimum Pitch the map can be displayed at.

      The default and lower bound for minPitch Pitch is 0.

      Parameters:
      minPitch - The new minimum Pitch.
    • getMinPitch

      public double getMinPitch()

      Gets the minimum Pitch the map can be displayed at.

      Returns:
      The minimum Pitch.
    • setMaxPitchPreference

      public void setMaxPitchPreference(@FloatRange(from=0.0,to=60.0) double maxPitch)

      Sets the maximum Pitch the map can be displayed at.

      The default and upper bound for maximum Pitch is 60.

      Parameters:
      maxPitch - The new maximum Pitch.
    • getMaxPitch

      public double getMaxPitch()

      Gets the maximum Pitch the map can be displayed at.

      Returns:
      The maximum Pitch.
    • getUiSettings

      @NonNull public UiSettings getUiSettings()
      Gets the user interface settings for the map.
      Returns:
      the UiSettings associated with this map
    • getProjection

      @NonNull public Projection getProjection()
      Get the Projection object that you can use to convert between screen coordinates and latitude/longitude coordinates.
      Returns:
      the Projection associated with this map
    • cancelTransitions

      public void cancelTransitions()
      Cancels ongoing animations.

      This invokes the TrimbleMapsMap.CancelableCallback for ongoing camera updates.

    • getCameraPosition

      @NonNull public final com.trimblemaps.mapsdk.camera.CameraPosition getCameraPosition()
      Gets the current position of the camera. The CameraPosition returned is a snapshot of the current position, and will not automatically update when the camera moves.
      Returns:
      The current position of the Camera.
    • setCameraPosition

      public void setCameraPosition(@NonNull com.trimblemaps.mapsdk.camera.CameraPosition cameraPosition)
      Repositions the camera according to the cameraPosition. The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position. See CameraUpdateFactory for a set of updates.
      Parameters:
      cameraPosition - the camera position to set
    • moveCamera

      public final void moveCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update)
      Repositions the camera according to the instructions defined in the update. The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position. See CameraUpdateFactory for a set of updates.
      Parameters:
      update - The change that should be applied to the camera.
    • moveCamera

      public final void moveCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Repositions the camera according to the instructions defined in the update. The move is instantaneous, and a subsequent getCameraPosition() will reflect the new position. See CameraUpdateFactory for a set of updates.
      Parameters:
      update - The change that should be applied to the camera
      callback - the callback to be invoked when an animation finishes or is canceled
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update)
      Gradually move the camera by the default duration, zoom will not be affected unless specified within CameraUpdate. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      See Also:
      • for a set of updates.
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Gradually move the camera by the default duration, zoom will not be affected unless specified within CameraUpdate. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      callback - An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. Do not update or ease the camera from within onCancel().
      See Also:
      • for a set of updates.
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs)
      Gradually move the camera by a specified duration in milliseconds, zoom will not be affected unless specified within CameraUpdate. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      See Also:
      • for a set of updates.
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Gradually move the camera by a specified duration in milliseconds, zoom will not be affected unless specified within CameraUpdate. A callback can be used to be notified when easing the camera stops. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.

      Note that this will cancel location tracking mode if enabled.

      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      callback - An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. Do not update or ease the camera from within onCancel().
      See Also:
      • for a set of updates.
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs, boolean easingInterpolator)
      Gradually move the camera by a specified duration in milliseconds, zoom will not be affected unless specified within CameraUpdate. A callback can be used to be notified when easing the camera stops. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.

      Note that this will cancel location tracking mode if enabled.

      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      easingInterpolator - True for easing interpolator, false for linear.
    • easeCamera

      public final void easeCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs, boolean easingInterpolator, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Gradually move the camera by a specified duration in milliseconds, zoom will not be affected unless specified within CameraUpdate. A callback can be used to be notified when easing the camera stops. If getCameraPosition() is called during the animation, it will return the current location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      easingInterpolator - True for easing interpolator, false for linear.
      callback - An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. Do not update or ease the camera from within onCancel().
    • animateCamera

      public final void animateCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update)
      Animate the camera to a new location defined within CameraUpdate using a transition animation that evokes powered flight. The animation will last the default amount of time. During the animation, a call to getCameraPosition() returns an intermediate location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      See Also:
      • for a set of updates.
    • animateCamera

      public final void animateCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Animate the camera to a new location defined within CameraUpdate using a transition animation that evokes powered flight. The animation will last the default amount of time. A callback can be used to be notified when animating the camera stops. During the animation, a call to getCameraPosition() returns an intermediate location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      callback - The callback to invoke from the main thread when the animation stops. If the animation completes normally, onFinish() is called; otherwise, onCancel() is called. Do not update or animate the camera from within onCancel().
      See Also:
      • for a set of updates.
    • animateCamera

      public final void animateCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs)
      Animate the camera to a new location defined within CameraUpdate using a transition animation that evokes powered flight. The animation will last a specified amount of time given in milliseconds. During the animation, a call to getCameraPosition() returns an intermediate location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      See Also:
      • for a set of updates.
    • animateCamera

      public final void animateCamera(@NonNull com.trimblemaps.mapsdk.camera.CameraUpdate update, int durationMs, @Nullable TrimbleMapsMap.CancelableCallback callback)
      Animate the camera to a new location defined within CameraUpdate using a transition animation that evokes powered flight. The animation will last a specified amount of time given in milliseconds. A callback can be used to be notified when animating the camera stops. During the animation, a call to getCameraPosition() returns an intermediate location of the camera in flight.
      Parameters:
      update - The change that should be applied to the camera.
      durationMs - The duration of the animation in milliseconds. This must be strictly positive, otherwise an IllegalArgumentException will be thrown.
      callback - An optional callback to be notified from the main thread when the animation stops. If the animation stops due to its natural completion, the callback will be notified with onFinish(). If the animation stops due to interruption by a later camera movement or a user gesture, onCancel() will be called. Do not update or animate the camera from within onCancel(). If a callback isn't required, leave it as null.
      See Also:
      • for a set of updates.
    • scrollBy

      public void scrollBy(float x, float y)
      Scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y directions.
      Parameters:
      x - Amount of pixels to scroll to in x direction
      y - Amount of pixels to scroll to in y direction
    • scrollBy

      public void scrollBy(float x, float y, long duration)
      Scrolls the camera over the map, shifting the center of view by the specified number of pixels in the x and y directions.
      Parameters:
      x - Amount of pixels to scroll to in x direction
      y - Amount of pixels to scroll to in y direction
      duration - Amount of time the scrolling should take
    • resetNorth

      public void resetNorth()
      Resets the map view to face north.
    • setFocalBearing

      public void setFocalBearing(double bearing, float focalX, float focalY, long duration)
      Transform the map bearing given a bearing, focal point coordinates, and a duration.
      Parameters:
      bearing - The bearing of the Map to be transformed to
      focalX - The x coordinate of the focal point
      focalY - The y coordinate of the focal point
      duration - The duration of the transformation
    • getHeight

      public float getHeight()
      Returns the measured height of the Map.
      Returns:
      the height of the map
    • getWidth

      public float getWidth()
      Returns the measured width of the Map.
      Returns:
      the width of the map
    • setOfflineRegionDefinition

      public void setOfflineRegionDefinition(@NonNull com.trimblemaps.mapsdk.offline.OfflineRegionDefinition definition)
      Loads a new style from the specified offline region definition and moves the map camera to that region.
      Parameters:
      definition - the offline region definition
      See Also:
      • OfflineRegionDefinition
    • setOfflineRegionDefinition

      public void setOfflineRegionDefinition(@NonNull com.trimblemaps.mapsdk.offline.OfflineRegionDefinition definition, @Nullable Style.OnStyleLoaded callback)
      Loads a new style from the specified offline region definition and moves the map camera to that region.
      Parameters:
      definition - the offline region definition
      callback - the callback to be invoked when the style has loaded
      See Also:
      • OfflineRegionDefinition
    • isDebugActive

      public boolean isDebugActive()
      Returns whether the map debug information is currently shown.
      Returns:
      If true, map debug information is currently shown.
    • setDebugActive

      public void setDebugActive(boolean debugActive)

      Changes whether the map debug information is shown.

      The default value is false.
      Parameters:
      debugActive - If true, map debug information is shown.
    • cycleDebugOptions

      @Deprecated public void cycleDebugOptions()
      Deprecated.

      Cycles through the map debug options.

      The value of isDebugActive reflects whether there are any map debug options enabled or disabled.
      See Also:
    • setStyle

      public void setStyle(String style)
      Loads a new map style from the specified bundled style.

      This method is asynchronous and will return before the style finishes loading. If you wish to wait for the map to finish loading, listen to the MapView.OnDidFinishLoadingStyleListener callback or use the setStyle(String, Style.OnStyleLoaded) method instead.

      If the style fails to load or an invalid style URL is set, the map view will become blank. An error message will be logged in the Android logcat and MapView.OnDidFailLoadingMapListener callback will be triggered.
      Parameters:
      style - The bundled style
      See Also:
    • setStyle

      public void setStyle(String style, Style.OnStyleLoaded callback)
      Loads a new map style from the specified bundled style.

      If the style fails to load or an invalid style URL is set, the map view will become blank. An error message will be logged in the Android logcat and MapView.OnDidFailLoadingMapListener callback will be triggered.

      Parameters:
      style - The bundled style
      callback - The callback to be invoked when the style has loaded
      See Also:
    • setStyle

      public void setStyle(Style.Builder builder)
      Loads a new map style from the specified builder.

      If the builder fails to load, the map view will become blank. An error message will be logged in the Android logcat and MapView.OnDidFailLoadingMapListener callback will be triggered. If you wish to wait for the map to finish loading, listen to the MapView.OnDidFinishLoadingStyleListener callback or use the setStyle(String, Style.OnStyleLoaded) instead.

      Parameters:
      builder - The style builder
      See Also:
    • setStyle

      public void setStyle(Style.Builder builder, Style.OnStyleLoaded callback)
      Loads a new map style from the specified builder.

      If the builder fails to load, the map view will become blank. An error message will be logged in the Android logcat and MapView.OnDidFailLoadingMapListener callback will be triggered.

      Parameters:
      builder - The style builder
      callback - The callback to be invoked when the style has loaded
      See Also:
    • getComponent

      public MapComponent getComponent(com.trimblemaps.mapsdk.maps.TrimbleMapsMap.TrimbleLayer layer)
    • toggleComponentVisibility

      public void toggleComponentVisibility(com.trimblemaps.mapsdk.maps.TrimbleMapsMap.TrimbleLayer layer)
    • isTrafficVisible

      public boolean isTrafficVisible()
    • setTrafficVisibility

      public void setTrafficVisibility(boolean isVisible)
    • toggleTrafficVisibility

      public void toggleTrafficVisibility()
    • isWeatherAlertVisible

      public boolean isWeatherAlertVisible()
    • setWeatherAlertVisibility

      public void setWeatherAlertVisibility(boolean isVisible)
    • toggleWeatherAlertVisibility

      public void toggleWeatherAlertVisibility()
    • isWeatherRadarVisible

      public boolean isWeatherRadarVisible()
    • setWeatherRadarVisibility

      public void setWeatherRadarVisibility(boolean isVisible)
    • toggleWeatherRadarVisibility

      public void toggleWeatherRadarVisibility()
    • isRoadSurfaceVisible

      public boolean isRoadSurfaceVisible()
    • setRoadSurfaceVisibility

      public void setRoadSurfaceVisibility(boolean isVisible)
    • toggleRoadSurfaceVisibility

      public void toggleRoadSurfaceVisibility()
    • is3dBuildingVisible

      public boolean is3dBuildingVisible()
    • set3dBuildingVisibility

      public void set3dBuildingVisibility(boolean isVisible)
    • toggle3dBuildingVisibility

      public void toggle3dBuildingVisibility()
    • isPoiVisible

      public boolean isPoiVisible()
    • setPoiVisibility

      public void setPoiVisibility(boolean isVisible)
    • togglePoiVisibility

      public void togglePoiVisibility()
    • isTruckRestrictionsVisible

      public boolean isTruckRestrictionsVisible()
    • setTruckRestrictionsFilter

      public void setTruckRestrictionsFilter(TruckRestrictionsFilter truckRestrictionsFilter)
    • setTruckRestrictionsVisibility

      public void setTruckRestrictionsVisibility(boolean isVisible)
    • toggleTruckRestrictionsVisibility

      public void toggleTruckRestrictionsVisibility()
    • isAddressVisible

      public boolean isAddressVisible()
    • setAddressVisibility

      public void setAddressVisibility(boolean isVisible)
    • toggleAddressVisibility

      public void toggleAddressVisibility()
    • isAvoidFavorsVisible

      public boolean isAvoidFavorsVisible()
    • setAvoidFavorsVisibility

      public void setAvoidFavorsVisibility(boolean isVisible)
    • toggleAvoidFavorsVisibility

      public void toggleAvoidFavorsVisibility()
    • setAvoidFavorsFilter

      public void setAvoidFavorsFilter(List<Integer> setIds)
    • addMarker

      @Deprecated @NonNull public Marker addMarker(@NonNull MarkerOptions markerOptions)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Adds a marker to this map.

      The marker's icon is rendered on the map at the location Marker.position. If Marker.title is defined, the map shows an info box with the marker's title and snippet.
      Parameters:
      markerOptions - A marker options object that defines how to render the marker
      Returns:
      The Marker that was added to the map
    • addMarker

      @Deprecated @NonNull public Marker addMarker(@NonNull BaseMarkerOptions markerOptions)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Adds a marker to this map.

      The marker's icon is rendered on the map at the location Marker.position. If Marker.title is defined, the map shows an info box with the marker's title and snippet.
      Parameters:
      markerOptions - A marker options object that defines how to render the marker
      Returns:
      The Marker that was added to the map
    • addMarkers

      @Deprecated @NonNull public List<Marker> addMarkers(@NonNull List<? extends BaseMarkerOptions> markerOptionsList)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Adds multiple markers to this map.

      The marker's icon is rendered on the map at the location Marker.position. If Marker.title is defined, the map shows an info box with the marker's title and snippet.
      Parameters:
      markerOptionsList - A list of marker options objects that defines how to render the markers
      Returns:
      A list of the Markers that were added to the map
    • updateMarker

      @Deprecated public void updateMarker(@NonNull Marker updatedMarker)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Updates a marker on this map. Does nothing if the marker isn't already added.

      Parameters:
      updatedMarker - An updated marker object
    • addPolyline

      @Deprecated @NonNull public Polyline addPolyline(@NonNull PolylineOptions polylineOptions)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Adds a polyline to this map.
      Parameters:
      polylineOptions - A polyline options object that defines how to render the polyline
      Returns:
      The Polyine that was added to the map
    • addPolylines

      @Deprecated @NonNull public List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Adds multiple polylines to this map.
      Parameters:
      polylineOptionsList - A list of polyline options objects that defines how to render the polylines.
      Returns:
      A list of the Polylines that were added to the map.
    • updatePolyline

      @Deprecated public void updatePolyline(@NonNull Polyline polyline)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Update a polyline on this map.
      Parameters:
      polyline - An updated polyline object.
    • addPolygon

      @Deprecated @NonNull public Polygon addPolygon(@NonNull PolygonOptions polygonOptions)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Adds a polygon to this map.
      Parameters:
      polygonOptions - A polygon options object that defines how to render the polygon.
      Returns:
      The Polygon that was added to the map.
    • addPolygons

      @Deprecated @NonNull public List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Adds multiple polygons to this map.
      Parameters:
      polygonOptionsList - A list of polygon options objects that defines how to render the polygons
      Returns:
      A list of the Polygons that were added to the map
    • updatePolygon

      @Deprecated public void updatePolygon(@NonNull Polygon polygon)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Update a polygon on this map.
      Parameters:
      polygon - An updated polygon object
    • removeMarker

      @Deprecated public void removeMarker(@NonNull Marker marker)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Convenience method for removing a Marker from the map.

      Calls removeAnnotation() internally.
      Parameters:
      marker - Marker to remove
    • removePolyline

      @Deprecated public void removePolyline(@NonNull Polyline polyline)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Convenience method for removing a Polyline from the map.

      Calls removeAnnotation() internally.
      Parameters:
      polyline - Polyline to remove
    • removePolygon

      @Deprecated public void removePolygon(@NonNull Polygon polygon)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Convenience method for removing a Polygon from the map.

      Calls removeAnnotation() internally.
      Parameters:
      polygon - Polygon to remove
    • removeAnnotation

      @Deprecated public void removeAnnotation(@NonNull Annotation annotation)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Removes an annotation from the map.
      Parameters:
      annotation - The annotation object to remove.
    • removeAnnotation

      @Deprecated public void removeAnnotation(long id)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Removes an annotation from the map
      Parameters:
      id - The identifier associated to the annotation to be removed
    • removeAnnotations

      @Deprecated public void removeAnnotations(@NonNull List<? extends Annotation> annotationList)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Removes multiple annotations from the map.
      Parameters:
      annotationList - A list of annotation objects to remove.
    • removeAnnotations

      @Deprecated public void removeAnnotations()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Removes all annotations from the map.
    • clear

      @Deprecated public void clear()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Removes all markers, polylines, polygons, overlays, etc from the map.
    • getAnnotation

      @Deprecated @Nullable public Annotation getAnnotation(long id)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Return a annotation based on its id.
      Parameters:
      id - the id used to look up an annotation
      Returns:
      An annotation with a matched id, null is returned if no match was found
    • getAnnotations

      @Deprecated @NonNull public List<Annotation> getAnnotations()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Returns a list of all the annotations on the map.
      Returns:
      A list of all the annotation objects. The returned object is a copy so modifying this list will not update the map
    • getMarkers

      @Deprecated @NonNull public List<Marker> getMarkers()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Returns a list of all the markers on the map.
      Returns:
      A list of all the markers objects. The returned object is a copy so modifying this list will not update the map.
    • getPolygons

      @Deprecated @NonNull public List<Polygon> getPolygons()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Returns a list of all the polygons on the map.
      Returns:
      A list of all the polygon objects. The returned object is a copy so modifying this list will not update the map.
    • getPolylines

      @Deprecated @NonNull public List<Polyline> getPolylines()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Returns a list of all the polylines on the map.
      Returns:
      A list of all the polylines objects. The returned object is a copy so modifying this list will not update the map.
    • setOnMarkerClickListener

      @Deprecated public void setOnMarkerClickListener(@Nullable TrimbleMapsMap.OnMarkerClickListener listener)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Sets a callback that's invoked when the user clicks on a marker.
      Parameters:
      listener - The callback that's invoked when the user clicks on a marker. To unset the callback, use null.
    • setOnPolygonClickListener

      @Deprecated public void setOnPolygonClickListener(@Nullable TrimbleMapsMap.OnPolygonClickListener listener)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Sets a callback that's invoked when the user clicks on a polygon.
      Parameters:
      listener - The callback that's invoked when the user clicks on a polygon. To unset the callback, use null.
    • setOnPolylineClickListener

      @Deprecated public void setOnPolylineClickListener(@Nullable TrimbleMapsMap.OnPolylineClickListener listener)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Sets a callback that's invoked when the user clicks on a polyline.
      Parameters:
      listener - The callback that's invoked when the user clicks on a polyline. To unset the callback, use null.
    • selectMarker

      @Deprecated public void selectMarker(@NonNull Marker marker)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Selects a marker. The selected marker will have it's info window opened. Any other open info windows will be closed unless isAllowConcurrentMultipleOpenInfoWindows() is true.

      Selecting an already selected marker will have no effect.
      Parameters:
      marker - The marker to select.
    • deselectMarkers

      @Deprecated public void deselectMarkers()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Deselects any currently selected marker. All markers will have it's info window closed.
    • deselectMarker

      @Deprecated public void deselectMarker(@NonNull Marker marker)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Deselects a currently selected marker. The selected marker will have it's info window closed.
      Parameters:
      marker - the marker to deselect
    • getSelectedMarkers

      @Deprecated @NonNull public List<Marker> getSelectedMarkers()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Gets the currently selected marker.
      Returns:
      The currently selected marker.
    • setInfoWindowAdapter

      @Deprecated public void setInfoWindowAdapter(@Nullable TrimbleMapsMap.InfoWindowAdapter infoWindowAdapter)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead

      Sets a custom renderer for the contents of info window.

      When set your callback is invoked when an info window is about to be shown. By returning a custom View, the default info window will be replaced.
      Parameters:
      infoWindowAdapter - The callback to be invoked when an info window will be shown. To unset the callback, use null.
    • getInfoWindowAdapter

      @Deprecated @Nullable public TrimbleMapsMap.InfoWindowAdapter getInfoWindowAdapter()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Gets the callback to be invoked when an info window will be shown.
      Returns:
      The callback to be invoked when an info window will be shown.
    • setAllowConcurrentMultipleOpenInfoWindows

      @Deprecated public void setAllowConcurrentMultipleOpenInfoWindows(boolean allow)
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Changes whether the map allows concurrent multiple infowindows to be shown.
      Parameters:
      allow - If true, map allows concurrent multiple infowindows to be shown.
    • isAllowConcurrentMultipleOpenInfoWindows

      @Deprecated public boolean isAllowConcurrentMultipleOpenInfoWindows()
      Deprecated.
      Use TrimbleMaps Annotation Plugin instead instead
      Returns whether the map allows concurrent multiple infowindows to be shown.
      Returns:
      If true, map allows concurrent multiple infowindows to be shown.
    • setLatLngBoundsForCameraTarget

      public void setLatLngBoundsForCameraTarget(@Nullable com.trimblemaps.mapsdk.geometry.LatLngBounds latLngBounds)
      Sets a LatLngBounds that constraints map transformations to this bounds.

      Set to null to clear current bounds, newly set bounds will override previously set bounds.

      Parameters:
      latLngBounds - the bounds to constrain the map with
    • getCameraForLatLngBounds

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForLatLngBounds(@NonNull com.trimblemaps.mapsdk.geometry.LatLngBounds latLngBounds)
      Get a camera position that fits a provided bounds and the current camera tilt and bearing.
      Parameters:
      latLngBounds - the bounds to set the map with
      Returns:
      the camera position that fits the bounds
    • getCameraForLatLngBounds

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForLatLngBounds(@NonNull com.trimblemaps.mapsdk.geometry.LatLngBounds latLngBounds, @NonNull @Size(4L) int[] padding)
      Get a camera position that fits a provided bounds and padding and the current camera tilt and bearing.
      Parameters:
      latLngBounds - the bounds to set the map with
      padding - the padding to apply to the bounds
      Returns:
      the camera position that fits the bounds and padding
    • getCameraForLatLngBounds

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForLatLngBounds(@NonNull com.trimblemaps.mapsdk.geometry.LatLngBounds latLngBounds, @FloatRange(from=0.0,to=360.0) double bearing, @FloatRange(from=0.0,to=60.0) double tilt)
      Get a camera position that fits a provided bounds, bearing and tilt.
      Parameters:
      latLngBounds - the bounds to set the map with
      bearing - the bearing to transform the camera position with
      tilt - to transform the camera position with
      Returns:
      the camera position that fits the bounds and given bearing and tilt
    • getCameraForLatLngBounds

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForLatLngBounds(@NonNull com.trimblemaps.mapsdk.geometry.LatLngBounds latLngBounds, @NonNull @Size(4L) int[] padding, @FloatRange(from=0.0,to=360.0) double bearing, @FloatRange(from=0.0,to=60.0) double tilt)
      Get a camera position that fits a provided bounds, padding, bearing and tilt.
      Parameters:
      latLngBounds - the bounds to set the map with
      padding - the padding to apply to the bounds
      bearing - the bearing to transform the camera position with
      tilt - to transform the camera position with
      Returns:
      the camera position that fits the bounds, bearing and tilt
    • getCameraForGeometry

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForGeometry(@NonNull com.trimblemaps.geojson.Geometry geometry)
      Get a camera position that fits a provided shape.
      Parameters:
      geometry - the geometry to wraps the map with
      Returns:
      the camera position that fits the geometry inside
    • getCameraForGeometry

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForGeometry(@NonNull com.trimblemaps.geojson.Geometry geometry, @NonNull @Size(4L) int[] padding)
      Get a camera position that fits a provided shape and padding.
      Parameters:
      geometry - the geometry to wraps the map with
      padding - the padding to apply to the bounds
      Returns:
      the camera position that fits the geometry inside and padding
    • getCameraForGeometry

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForGeometry(@NonNull com.trimblemaps.geojson.Geometry geometry, @FloatRange(from=0.0,to=360.0) double bearing, @FloatRange(from=0.0,to=60.0) double tilt)
      Get a camera position that fits a provided shape with a given bearing and tilt.
      Parameters:
      geometry - the geometry to wraps the map with
      bearing - the bearing at which to compute the geometry's bounds
      tilt - the tilt at which to compute the geometry's bounds
      Returns:
      the camera position that the geometry inside with bearing and tilt
    • getCameraForGeometry

      @Nullable public com.trimblemaps.mapsdk.camera.CameraPosition getCameraForGeometry(@NonNull com.trimblemaps.geojson.Geometry geometry, @NonNull @Size(4L) int[] padding, @FloatRange(from=0.0,to=360.0) double bearing, @FloatRange(from=0.0,to=60.0) double tilt)
      Get a camera position that fits a provided shape with a given padding, bearing and tilt.
      Parameters:
      geometry - the geometry to wraps the map with
      padding - the padding to apply to the bounds
      bearing - the bearing at which to compute the geometry's bounds
      tilt - the tilt at which to compute the geometry's bounds
      Returns:
      the camera position that fits the geometry inside with padding, bearing and tilt
    • setPadding

      @Deprecated public void setPadding(int left, int top, int right, int bottom)
      Deprecated.
      Use CameraPosition.Builder.padding(double, double, double, double) or CameraUpdateFactory.paddingTo(double, double, double, double) instead.

      Sets the distance from the edges of the map view's frame to the edges of the map view's logical viewport.

      When the value of this property is equal to {0,0,0,0}, viewport properties such as 'centerCoordinate' assume a viewport that matches the map view's frame. Otherwise, those properties are inset, excluding part of the frame from the viewport. For instance, if the only the top edge is inset, the map center is effectively shifted downward.

      This method sets the padding "lazily". This means that the padding is going to be applied with the next camera transformation. To apply the padding immediately use CameraPosition.Builder.padding(double, double, double, double) or CameraUpdateFactory.paddingTo(double, double, double, double).

      Parameters:
      left - The left margin in pixels.
      top - The top margin in pixels.
      right - The right margin in pixels.
      bottom - The bottom margin in pixels.
    • getPadding

      @Deprecated @NonNull public int[] getPadding()
      Deprecated.
      Use CameraPosition.padding instead.
      Returns the current configured content padding on map view. This might return the currently visible padding or the padding cached but not yet applied by setPadding(int, int, int, int).
      Returns:
      An array with length 4 in the LTRB order.
    • addOnCameraIdleListener

      public void addOnCameraIdleListener(@NonNull TrimbleMapsMap.OnCameraIdleListener listener)
      Adds a callback that is invoked when camera movement has ended.
      Parameters:
      listener - the listener to notify
    • removeOnCameraIdleListener

      public void removeOnCameraIdleListener(@NonNull TrimbleMapsMap.OnCameraIdleListener listener)
      Removes a callback that is invoked when camera movement has ended.
      Parameters:
      listener - the listener to remove
    • addOnCameraMoveCancelListener

      public void addOnCameraMoveCancelListener(@NonNull TrimbleMapsMap.OnCameraMoveCanceledListener listener)
      Adds a callback that is invoked when camera movement was cancelled.
      Parameters:
      listener - the listener to notify
    • removeOnCameraMoveCancelListener

      public void removeOnCameraMoveCancelListener(@NonNull TrimbleMapsMap.OnCameraMoveCanceledListener listener)
      Removes a callback that is invoked when camera movement was cancelled.
      Parameters:
      listener - the listener to remove
    • addOnCameraMoveStartedListener

      public void addOnCameraMoveStartedListener(@NonNull TrimbleMapsMap.OnCameraMoveStartedListener listener)
      Adds a callback that is invoked when camera movement has started.
      Parameters:
      listener - the listener to notify
    • removeOnCameraMoveStartedListener

      public void removeOnCameraMoveStartedListener(@NonNull TrimbleMapsMap.OnCameraMoveStartedListener listener)
      Removes a callback that is invoked when camera movement has started.
      Parameters:
      listener - the listener to remove
    • addOnCameraMoveListener

      public void addOnCameraMoveListener(@NonNull TrimbleMapsMap.OnCameraMoveListener listener)
      Adds a callback that is invoked when camera position changes.
      Parameters:
      listener - the listener to notify
    • removeOnCameraMoveListener

      public void removeOnCameraMoveListener(@NonNull TrimbleMapsMap.OnCameraMoveListener listener)
      Removes a callback that is invoked when camera position changes.
      Parameters:
      listener - the listener to remove
    • setOnFpsChangedListener

      public void setOnFpsChangedListener(@Nullable TrimbleMapsMap.OnFpsChangedListener listener)
      Sets a callback that's invoked on every frame rendered to the map view.
      Parameters:
      listener - The callback that's invoked on every frame rendered to the map view. To unset the callback, use null.
    • addOnFlingListener

      public void addOnFlingListener(@NonNull TrimbleMapsMap.OnFlingListener listener)
      Adds a callback that's invoked when the map is flinged.
      Parameters:
      listener - The callback that's invoked when the map is flinged.
    • removeOnFlingListener

      public void removeOnFlingListener(@NonNull TrimbleMapsMap.OnFlingListener listener)
      Removes a callback that's invoked when the map is flinged.
      Parameters:
      listener - The callback that's invoked when the map is flinged.
    • addOnMoveListener

      public void addOnMoveListener(@NonNull TrimbleMapsMap.OnMoveListener listener)
      Adds a callback that's invoked when the map is moved.
      Parameters:
      listener - The callback that's invoked when the map is moved.
    • removeOnMoveListener

      public void removeOnMoveListener(@NonNull TrimbleMapsMap.OnMoveListener listener)
      Removes a callback that's invoked when the map is moved.
      Parameters:
      listener - The callback that's invoked when the map is moved.
    • addOnRotateListener

      public void addOnRotateListener(@NonNull TrimbleMapsMap.OnRotateListener listener)
      Adds a callback that's invoked when the map is rotated.
      Parameters:
      listener - The callback that's invoked when the map is rotated.
    • removeOnRotateListener

      public void removeOnRotateListener(@NonNull TrimbleMapsMap.OnRotateListener listener)
      Removes a callback that's invoked when the map is rotated.
      Parameters:
      listener - The callback that's invoked when the map is rotated.
    • addOnScaleListener

      public void addOnScaleListener(@NonNull TrimbleMapsMap.OnScaleListener listener)
      Adds a callback that's invoked when the map is scaled.
      Parameters:
      listener - The callback that's invoked when the map is scaled.
    • removeOnScaleListener

      public void removeOnScaleListener(@NonNull TrimbleMapsMap.OnScaleListener listener)
      Removes a callback that's invoked when the map is scaled.
      Parameters:
      listener - The callback that's invoked when the map is scaled.
    • addOnShoveListener

      public void addOnShoveListener(@NonNull TrimbleMapsMap.OnShoveListener listener)
      Adds a callback that's invoked when the map is tilted.
      Parameters:
      listener - The callback that's invoked when the map is tilted.
    • removeOnShoveListener

      public void removeOnShoveListener(@NonNull TrimbleMapsMap.OnShoveListener listener)
      Remove a callback that's invoked when the map is tilted.
      Parameters:
      listener - The callback that's invoked when the map is tilted.
    • setGesturesManager

      public void setGesturesManager(@NonNull com.trimblemaps.android.gestures.AndroidGesturesManager androidGesturesManager, boolean attachDefaultListeners, boolean setDefaultMutuallyExclusives)
      Sets a custom AndroidGesturesManager to handle MotionEvents registered by the MapView.
      Parameters:
      androidGesturesManager - Gestures manager that interprets gestures based on the motion events.
      attachDefaultListeners - If true, pre-defined listeners will be attach to change map based on AndroidGesturesManager callbacks.
      setDefaultMutuallyExclusives - If true, pre-defined mutually exclusive gesture sets will be added to the passed gestures manager.
      See Also:
    • getGesturesManager

      @NonNull public com.trimblemaps.android.gestures.AndroidGesturesManager getGesturesManager()
      Get current AndroidGesturesManager that handles MotionEvents registered by the MapView
      Returns:
      Current gestures manager.
    • cancelAllVelocityAnimations

      public void cancelAllVelocityAnimations()
      Interrupts any ongoing gesture velocity animations.
    • addOnMapClickListener

      public void addOnMapClickListener(@NonNull TrimbleMapsMap.OnMapClickListener listener)
      Adds a callback that's invoked when the user clicks on the map view.
      Parameters:
      listener - The callback that's invoked when the user clicks on the map view.
    • removeOnMapClickListener

      public void removeOnMapClickListener(@NonNull TrimbleMapsMap.OnMapClickListener listener)
      Removes a callback that's invoked when the user clicks on the map view.
      Parameters:
      listener - The callback that's invoked when the user clicks on the map view.
    • addOnMapLongClickListener

      public void addOnMapLongClickListener(@NonNull TrimbleMapsMap.OnMapLongClickListener listener)
      Adds a callback that's invoked when the user long clicks on the map view.
      Parameters:
      listener - The callback that's invoked when the user long clicks on the map view.
    • removeOnMapLongClickListener

      public void removeOnMapLongClickListener(@NonNull TrimbleMapsMap.OnMapLongClickListener listener)
      Removes a callback that's invoked when the user long clicks on the map view.
      Parameters:
      listener - The callback that's invoked when the user long clicks on the map view.
    • setOnInfoWindowClickListener

      public void setOnInfoWindowClickListener(@Nullable TrimbleMapsMap.OnInfoWindowClickListener listener)
      Sets a callback that's invoked when the user clicks on an info window.
      Parameters:
      listener - The callback that's invoked when the user clicks on an info window. To unset the callback, use null.
    • getOnInfoWindowClickListener

      @Nullable public TrimbleMapsMap.OnInfoWindowClickListener getOnInfoWindowClickListener()
      Return the InfoWindow click listener
      Returns:
      Current active InfoWindow Click Listener
    • setOnInfoWindowLongClickListener

      public void setOnInfoWindowLongClickListener(@Nullable TrimbleMapsMap.OnInfoWindowLongClickListener listener)
      Sets a callback that's invoked when a marker's info window is long pressed.
      Parameters:
      listener - The callback that's invoked when a marker's info window is long pressed. To unset the callback, use null.
    • getOnInfoWindowLongClickListener

      @Nullable public TrimbleMapsMap.OnInfoWindowLongClickListener getOnInfoWindowLongClickListener()
      Return the InfoWindow long click listener
      Returns:
      Current active InfoWindow long Click Listener
    • setOnInfoWindowCloseListener

      public void setOnInfoWindowCloseListener(@Nullable TrimbleMapsMap.OnInfoWindowCloseListener listener)
      Set an callback to be invoked when an InfoWindow closes.
      Parameters:
      listener - callback invoked when an InfoWindow closes
    • getOnInfoWindowCloseListener

      @Nullable public TrimbleMapsMap.OnInfoWindowCloseListener getOnInfoWindowCloseListener()
      Return the InfoWindow close listener
      Returns:
      Current active InfoWindow Close Listener
    • snapshot

      public void snapshot(@NonNull TrimbleMapsMap.SnapshotReadyCallback callback)
      Takes a snapshot of the map.
      Parameters:
      callback - Callback method invoked when the snapshot is taken.
    • queryRenderedFeatures

      @NonNull public List<com.trimblemaps.geojson.Feature> queryRenderedFeatures(@NonNull android.graphics.PointF coordinates, @Nullable String... layerIds)
      Queries the map for rendered features.

      Returns an empty list if either the map or underlying render surface has been destroyed.

      Parameters:
      coordinates - the point to query
      layerIds - optionally - only query these layers
      Returns:
      the list of feature
    • queryRenderedFeatures

      @NonNull public List<com.trimblemaps.geojson.Feature> queryRenderedFeatures(@NonNull android.graphics.PointF coordinates, @Nullable Expression filter, @Nullable String... layerIds)
      Queries the map for rendered features

      Returns an empty list if either the map or underlying render surface has been destroyed.

      Parameters:
      coordinates - the point to query
      filter - filters the returned features with an expression
      layerIds - optionally - only query these layers
      Returns:
      the list of feature
    • queryRenderedFeatures

      @NonNull public List<com.trimblemaps.geojson.Feature> queryRenderedFeatures(@NonNull android.graphics.RectF coordinates, @Nullable String... layerIds)
      Queries the map for rendered features

      Returns an empty list if either the map or underlying render surface has been destroyed.

      Parameters:
      coordinates - the box to query
      layerIds - optionally - only query these layers
      Returns:
      the list of feature
    • queryRenderedFeatures

      @NonNull public List<com.trimblemaps.geojson.Feature> queryRenderedFeatures(@NonNull android.graphics.RectF coordinates, @Nullable Expression filter, @Nullable String... layerIds)
      Queries the map for rendered features

      Returns an empty list if either the map or underlying render surface has been destroyed.

      Parameters:
      coordinates - the box to query
      filter - filters the returned features with an expression
      layerIds - optionally - only query these layers
      Returns:
      the list of feature
    • getLocationComponent

      @NonNull public LocationComponent getLocationComponent()
      Returns the LocationComponent that can be used to display user's location on the map.

      Use LocationComponent.activateLocationComponent(LocationComponentActivationOptions) or any overload to activate the component, then, enable it with LocationComponent.setLocationComponentEnabled(boolean).

      You can customize the location icon and more with LocationComponentOptions.

      Returns:
      the Location Component