TomTomMap
The TomTomMap class serves as the foundational gateway for integrating a various map-related features, offering extensive functionality for developer interaction with the Map and customization of its behavior.
MapOptions are required to initialize the map, specifying its style, camera options, style mode and more.
To obtain the TomTomMap class, use the MapProvider.getMapAsync function provided by MapView or MapFragment classes.
val mapOptions = MapOptions(mapKey = "YOUR_TOMTOM_API_KEY")
val mapFragment = MapFragment.newInstance(mapOptions)
supportFragmentManager.beginTransaction()
.replace(R.id.map_container, mapFragment)
.commit()
mapFragment.getMapAsync { tomtomMap: TomTomMap ->
/* Your code goes here */
}
All functionalities exposed by TomTomMap are implemented by correlated controllers. For example, StyleController allows you to load and apply a custom map style.
mapFragment.getMapAsync { tomtomMap: TomTomMap ->
tomTomMap.setStyleMode(StyleMode.DARK)
}
Note that the TomTomMap methods should be called from the application's main thread. Invoking them from other threads can lead to unexpected behavior or exceptions.
See also
Inherited properties
The current CameraPosition.
The current CameraTrackingMode.
Describes the latest available (last known) GeoLocation of the device. The value may be null when the LocationProvider has never updated the current location. For example, it may be be caused by invalid GPS Fix being deliver to the device.
Flag determining whether the current location marker is located within the visible area of the screen.
Flag determining whether markers fade with increased distance. True by default.
Flag determining whether markers shrink with increased distance. True by default.
Flag determining whether the map panning with two or more fingers is enabled. True by default.
Flag determining whether the rotation is enabled. True by default.
Flag determining whether the scroll gesture is enabled. True by default.
Flag determining whether the tilt (aka shove) gesture is enabled. True by default.
Flag determining whether the zoom gesture is enabled. True by default.
Determines if the location is accurate enough for the user to rely on. The default is for locations with an accuracy of more then 50 meters to be treated as unreliable.
Defines the range of marker fading in meters. In the range 0, markersFadingRange.first markers don't fade. In the range markersFadingRange.first, markersFadingRange.last marker transparency gradually changes from fully opaque to fully transparent.
Defines the range of marker shrinking in meters. In the range 0, markersFadingRange.first markers are normal size. In the range markersFadingRange.first, markersFadingRange.last marker size gradually changes from normal to minimum possible size.
Functions
Inherited functions
Registers the CameraChangeListener that will be notified about any change of the camera properties.
Registers the CameraSteadyListener that will be notified when the camera becomes steady after applying changes on its properties.
Adds a new Circle based on the given CircleOptions.
Registers the CircleClickListener that will be notified about any circle being clicked. The clicked Circle becomes a parameter of the CircleClickListener.onCircleClicked callback.
Registers LocationMarkerClickListener that will be notified about the click (aka tap) gesture recognized on the location marker. Both, the clicked position on the screen and the underlying location on the map, become parameters of the LocationMarkerClickListener.onLocationMarkerClick callback.
Registers MapClickListener which is notified when the map has been clicked (tapped).
Registers MapDoubleClickListener which is notified when the map double click (double tap) gesture has been recognized.
Registers MapLongClickListener which is notified when the map long click (long press) gesture has been recognized.
Registers MapPanningListener which is notified when user performs the panning gesture on the map.
Adds a new Marker based on the given MarkerOptions.
Registers MarkerClickListener that will be notified about any Marker being clicked. The clicked Marker becomes a parameter of the MarkerClickListener.onMarkerClicked callback.
Registers MarkerLongClickListener that will be notified about the long press gesture recognized on the Marker. The clicked Marker becomes a parameter of the MarkerLongClickListener.onMarkerLongClicked callback.
Adds a group of Marker based on the given MarkerOptions list.
Registers MarkerLongClickListener that will be notified when marker is selected or deselected. The selected Marker becomes a parameter of the MarkerSelectionListener.onMarkerSelectedStateChanged callback.
Adds a new Polygon based on the given PolygonOptions.
Registers the PolygonClickListener that will be notified about any Polygon being clicked. The clicked Polygon becomes a parameter of the PolygonClickListener.onPolygonClicked callback.
Create new PolygonOverlay using provided options.
Adds a new Polyline based on the given PolylineOptions.
Registers the PolylineClickListener that will be notified about any Polyline being clicked. The clicked Polyline becomes a parameter of the PolylineClickListener.onPolylineClicked callback.
Adds a new Route based on the given RouteOptions.
Registers RouteClickListener that will be notified about any route being clicked. The clicked Route becomes a parameter of the RouteClickListener.onRouteClick callback.
Add TrafficIncidentClickListener that will be notified when user taps on the traffic incident on the map.
Moves the camera according to the given CameraOptions and animates the transition.
Allows to change the default gesture detection behaviour. For example invocation of this method with the following parameters: setExclusiveGestures(GestureType.Rotation, setOf(GestureType.Scale)) results in GestureType.Rotation being ignored if its not already ongoing before GestureType.Scale.
Disables the location marker so it becomes inactive and invisible.
Enables the location marker based on the supplied LocationMarkerOptions, replacing any existing location marker already visible. The location marker visualizes the users location on the map and can be of three types: CHEVRON: A vehicle position indicator primarily for use in turn-by-turn guidance. POINTER: A user location pointer, primarily for use in browsing or pedestrian modes. CUSTOM: A customizable model supplied by the developer.
Gets the caption asynchronously.
Gets the map copyright contents asynchronously.
Gets the currently set LocationProvider or returns null if none is set.
Provides the currently visible region as VisibleRegion.
Hide hill shading layer.
Hides all traffic flow.
Hides all traffic incidents.
Hides vehicle restrictions layers.
Loads new map style. Provided callback is called once operation finishes with either success or failure.
Immediately moves camera according to the given CameraOptions.
Converts a position on the map into the MapView point.
Removes the CameraChangeListener.
Removes the CameraSteadyListener.
Removes the CircleClickListener.
Removes all Circle elements with the provided tag from the map. If tag is null then all circles that don't have a tag will be removed. The tag is set with the CircleOptions.tag property.
Removes the LocationMarkerClickListener.
Removes the MapClickListener.
Removes the MapDoubleClickListener.
Removes the MapLongClickListener.
Removes the MapPanningListener.
Removes the MarkerClickListener.
Removes the MarkerLongClickListener.
Removes all Marker elements with provided tag from the map.
Removes the MarkerSelectionListener.
Removes the PolygonClickListener.
Removes all PolygonOverlay elements from the map.
Removes all Polygon elements with the provided tag from the map. If tag is null then all polygons that don't have a tag will be removed. The tag is set with the PolygonOptions.tag property.
Removes the PolylineClickListener.
Removes all Polyline elements with the provided tag from the map. If tag is null then all polylines that don't have a tag will be removed. The tag is set with the PolylineOptions.tag property.
Removes the RouteClickListener.
Removes all previously added routes.
Remove TrafficIncidentClickListener.
Gets rendered features within a given bounding box.
Gets rendered features at a given coordinate.
Applies a frame rate cap on the map renderer. It is useful for scenarios where the map is not fully visible to the user, and there is no need to render it with its full performance.
Sets map language. If the requested locale is unsupported, the map falls back to the NGT (Neutral Ground Truth); this means official languages for all regions in local scripts (if available).
Sets new LocationProvider. Location marker position is then set based on updates that are received from that engine.
Sets padding on the MapView to determine space for the safe area. The safe area is the part of the viewport which is considered completely visible by the user i.e. not covered by UI components such as buttons or sliders.
Configures style mode. See StyleMode for more info.
Shows hill shading layer in the current style.
Shows all traffic flow.
Shows all traffic incidents.
Shows vehicle restrictions layers if hidden previously.
Shows vehicle restriction for given vehicle. It is required that StandardStyles.VEHICLE_RESTRICTIONS is set.
Updates vehicle. If StandardStyles.VEHICLE_RESTRICTIONS is selected restrictions will be visible.
Zooms the map to display all markers added to the map.
Zooms the map to display all markers with provided tag.
Zooms the map do display markers from the given list.
Updates camera view to fit all route points.
Updates camera view to fit all route points, plus additional padding.