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_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

Link copied to clipboard
open override val cameraPosition: CameraPosition

The current CameraPosition.

Link copied to clipboard

The current CameraTrackingMode.

Link copied to clipboard
open override val currentLocation: GeoLocation?

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.

Link copied to clipboard

Flag determining whether the current location marker is located within the visible area of the screen.

Link copied to clipboard
open override var isMarkersFadingEnabled: Boolean

Flag determining whether markers fade with increased distance. True by default.

Link copied to clipboard

Flag determining whether markers shrink with increased distance. True by default.

Link copied to clipboard

Flag determining whether the map panning with two or more fingers is enabled. True by default.

Link copied to clipboard
open override var isRotationEnabled: Boolean

Flag determining whether the rotation is enabled. True by default.

Link copied to clipboard
open override var isScrollEnabled: Boolean

Flag determining whether the scroll gesture is enabled. True by default.

Link copied to clipboard
open override var isTiltEnabled: Boolean

Flag determining whether the tilt (aka shove) gesture is enabled. True by default.

Link copied to clipboard
open override var isZoomEnabled: Boolean

Flag determining whether the zoom gesture is enabled. True by default.

Link copied to clipboard
open override val layers: List<Layer>

Returns all currently added Layer elements.

Link copied to clipboard

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.

Link copied to clipboard
open override var markersFadingRange: IntRange

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.

Link copied to clipboard
open override var markersShrinkingRange: IntRange

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.

Link copied to clipboard
open override val maxZoom: Double

Provides a maximum available value for the CameraOptions.zoom attribute.

Link copied to clipboard
open override val minZoom: Double

Provides a minimum available value for the CameraOptions.zoom attribute.

Link copied to clipboard
open override val routes: List<Route>

List of added Routes.

Functions

Link copied to clipboard
fun clear()

Removes all polylines, polygons, circles, routes and markers previously added to the map.

Inherited functions

Link copied to clipboard
open override fun addCameraChangeListener(listener: CameraChangeListener)

Registers the CameraChangeListener that will be notified about any change of the camera properties.

Link copied to clipboard
open override fun addCameraSteadyListener(listener: CameraSteadyListener)

Registers the CameraSteadyListener that will be notified when the camera becomes steady after applying changes on its properties.

Link copied to clipboard
open override fun addCircle(options: CircleOptions): Circle

Adds a new Circle based on the given CircleOptions.

Link copied to clipboard
open override fun addCircleClickListener(listener: CircleClickListener)

Registers the CircleClickListener that will be notified about any circle being clicked. The clicked Circle becomes a parameter of the CircleClickListener.onCircleClicked callback.

Link copied to clipboard

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.

Link copied to clipboard
open override fun addMapClickListener(listener: MapClickListener)

Registers MapClickListener which is notified when the map has been clicked (tapped).

Link copied to clipboard

Registers MapDoubleClickListener which is notified when the map double click (double tap) gesture has been recognized.

Link copied to clipboard
open override fun addMapLongClickListener(listener: MapLongClickListener)

Registers MapLongClickListener which is notified when the map long click (long press) gesture has been recognized.

Link copied to clipboard
open override fun addMapPanningListener(listener: MapPanningListener)

Registers MapPanningListener which is notified when user performs the panning gesture on the map.

Link copied to clipboard
open override fun addMarker(options: MarkerOptions): Marker

Adds a new Marker based on the given MarkerOptions.

Link copied to clipboard
open override fun addMarkerClickListener(listener: MarkerClickListener)

Registers MarkerClickListener that will be notified about any Marker being clicked. The clicked Marker becomes a parameter of the MarkerClickListener.onMarkerClicked callback.

Link copied to clipboard

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.

Link copied to clipboard
open override fun addMarkers(options: List<MarkerOptions>): List<Marker>

Adds a group of Marker based on the given MarkerOptions list.

Link copied to clipboard

Registers MarkerLongClickListener that will be notified when marker is selected or deselected. The selected Marker becomes a parameter of the MarkerSelectionListener.onMarkerSelectedStateChanged callback.

Link copied to clipboard
open override fun addPolygon(options: PolygonOptions): Polygon

Adds a new Polygon based on the given PolygonOptions.

Link copied to clipboard
open override fun addPolygonClickListener(listener: PolygonClickListener)

Registers the PolygonClickListener that will be notified about any Polygon being clicked. The clicked Polygon becomes a parameter of the PolygonClickListener.onPolygonClicked callback.

Link copied to clipboard

Create new PolygonOverlay using provided options.

Link copied to clipboard
open override fun addPolyline(options: PolylineOptions): Polyline

Adds a new Polyline based on the given PolylineOptions.

Link copied to clipboard
open override fun addPolylineClickListener(listener: PolylineClickListener)

Registers the PolylineClickListener that will be notified about any Polyline being clicked. The clicked Polyline becomes a parameter of the PolylineClickListener.onPolylineClicked callback.

Link copied to clipboard
open override fun addRoute(options: RouteOptions): Route

Adds a new Route based on the given RouteOptions.

Link copied to clipboard
open override fun addRouteClickListener(listener: RouteClickListener)

Registers RouteClickListener that will be notified about any route being clicked. The clicked Route becomes a parameter of the RouteClickListener.onRouteClick callback.

Link copied to clipboard

Add TrafficIncidentClickListener that will be notified when user taps on the traffic incident on the map.

Link copied to clipboard
open override fun animateCamera(options: CameraOptions, animationDuration: Duration?): Cancellable
open override fun animateCamera(options: CameraOptions, actionCallback: AnimateCameraCallback, animationDuration: Duration?): Cancellable

Moves the camera according to the given CameraOptions and animates the transition.

Link copied to clipboard
open override fun changeGestureExclusions(gesture: GestureType, exclusions: Set<GestureType>)

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.

Link copied to clipboard

Converts a Point on the MapView to a position on the map. Returns a Result with a GeoPoint or PointConversionFailure when it cannot obtain a coordinate from the given point. This Result can occur when the point is not on the map.

Link copied to clipboard
open override fun disableLocationMarker()

Disables the location marker so it becomes inactive and invisible.

Link copied to clipboard
open override fun enableLocationMarker(options: LocationMarkerOptions)

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.

Link copied to clipboard

Gets the caption synchronously.

open override fun getCaption(callback: CopyrightsFetchingCallback): Cancellable

Gets the caption asynchronously.

Link copied to clipboard

Gets the map copyright contents synchronously.

Gets the map copyright contents asynchronously.

Link copied to clipboard

Gets the currently set LocationProvider or returns null if none is set.

Link copied to clipboard

Provides the currently visible region as VisibleRegion.

Link copied to clipboard
open override fun hideHillShading()

Hide hill shading layer.

Link copied to clipboard
open override fun hideTrafficFlow()

Hides all traffic flow.

Link copied to clipboard
open override fun hideTrafficIncidents()

Hides all traffic incidents.

Link copied to clipboard
open override fun hideVehicleRestrictions()

Hides vehicle restrictions layers.

Link copied to clipboard
open override fun loadStyle(style: StyleDescriptor, callback: StyleLoadingCallback): Cancellable

Loads new map style. Provided callback is called once operation finishes with either success or failure.

Link copied to clipboard
open override fun moveCamera(options: CameraOptions)

Immediately moves camera according to the given CameraOptions.

Link copied to clipboard
open override fun pointForCoordinate(coordinate: GeoPoint): Point

Converts a position on the map into the MapView point.

Link copied to clipboard

Removes the CameraChangeListener.

Link copied to clipboard

Removes the CameraSteadyListener.

Link copied to clipboard
open override fun removeCircleClickListener(listener: CircleClickListener)

Removes the CircleClickListener.

Link copied to clipboard
open override fun removeCircles(tag: String?)

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.

Link copied to clipboard

Removes the LocationMarkerClickListener.

Link copied to clipboard
open override fun removeMapClickListener(listener: MapClickListener)

Removes the MapClickListener.

Link copied to clipboard

Removes the MapDoubleClickListener.

Link copied to clipboard

Removes the MapLongClickListener.

Link copied to clipboard
open override fun removeMapPanningListener(listener: MapPanningListener)

Removes the MapPanningListener.

Link copied to clipboard
open override fun removeMarkerClickListener(listener: MarkerClickListener)

Removes the MarkerClickListener.

Link copied to clipboard

Removes the MarkerLongClickListener.

Link copied to clipboard
open override fun removeMarkers(tag: String?)

Removes all Marker elements with provided tag from the map.

Link copied to clipboard

Removes the MarkerSelectionListener.

Link copied to clipboard

Removes the PolygonClickListener.

Link copied to clipboard
open override fun removePolygonOverlays()

Removes all PolygonOverlay elements from the map.

Link copied to clipboard
open override fun removePolygons(tag: String?)

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.

Link copied to clipboard

Removes the PolylineClickListener.

Link copied to clipboard
open override fun removePolylines(tag: String?)

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.

Link copied to clipboard
open override fun removeRouteClickListener(listener: RouteClickListener)

Removes the RouteClickListener.

Link copied to clipboard
open override fun removeRoutes()

Removes all previously added routes.

Link copied to clipboard

Remove TrafficIncidentClickListener.

Link copied to clipboard
open override fun renderedFeatures(geoBoundingBox: GeoBoundingBox, options: RenderedFeatureQueryOptions): List<RenderedFeature>

Gets rendered features within a given bounding box.

Gets rendered features at a given coordinate.

Link copied to clipboard
open override fun setFrameRate(@IntRange(from = 1) frameRate: Int)

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.

Link copied to clipboard
open override fun setLanguage(language: Locale)

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).

Link copied to clipboard
open override fun setLocationProvider(engine: LocationProvider?)

Sets new LocationProvider. Location marker position is then set based on updates that are received from that engine.

Link copied to clipboard
open override fun setPadding(padding: Padding)

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.

Link copied to clipboard
open override fun setStyleMode(mode: StyleMode)

Configures style mode. See StyleMode for more info.

Link copied to clipboard
open override fun showHillShading()

Shows hill shading layer in the current style.

Link copied to clipboard
open override fun showTrafficFlow()

Shows all traffic flow.

Link copied to clipboard
open override fun showTrafficIncidents()

Shows all traffic incidents.

Link copied to clipboard
open override fun showVehicleRestrictions()

Shows vehicle restrictions layers if hidden previously.

open override fun showVehicleRestrictions(vehicle: Vehicle)

Shows vehicle restriction for given vehicle. It is required that StandardStyles.VEHICLE_RESTRICTIONS is set.

Link copied to clipboard
open override fun updateVehicle(vehicle: Vehicle)

Updates vehicle. If StandardStyles.VEHICLE_RESTRICTIONS is selected restrictions will be visible.

Link copied to clipboard
open override fun zoomToMarkers(padding: Int)

Zooms the map to display all markers added to the map.

open override fun zoomToMarkers(tag: String?, padding: Int)

Zooms the map to display all markers with provided tag.

open override fun zoomToMarkers(markers: List<Marker>, padding: Int)

Zooms the map do display markers from the given list.

Link copied to clipboard
open override fun zoomToRoutes()

Updates camera view to fit all route points.

open override fun zoomToRoutes(padding: Int)

Updates camera view to fit all route points, plus additional padding.