User location

The Extended flavor of Maps and Navigation SDK for Android is only available upon request. Contact Sales to get started.

The TomTom Map Display module allows you to show the current user location on the map. Location data is provided by the LocationProvider and is used to display the user location marker indicator on the map.

Using the location provider with the map

Location updates are generated by the LocationProvider. To receive them you need to provide the LocationProvider object to the TomTomMap. It will be used by the map to position the location marker according to the position updates.

tomTomMap.setLocationProvider(locationProvider)

You can also use the TomTomMap object to retrieve the currently used LocationProvider, access the latest user location, or check whether the location marker is visible on the screen.

Note that if the LocationProvider was not set, or did not provide any location data, the TomTomMap.currentLocation will not be returned.

val mapLocationProvider = tomTomMap.getLocationProvider()
val isLocationInVisibleArea = tomTomMap.isCurrentLocationInMapBoundingBox
val currentLocation: GeoLocation? = tomTomMap.currentLocation

Location marker

The user location is shown as a location marker on the map. To show it, first create LocationMarkerOptions.

val locationMarkerOptions =
LocationMarkerOptions(
type = Type.Chevron,
)

Then enable the location marker on the map. If a marker has already been set, the new one replaces it.

tomTomMap.enableLocationMarker(locationMarkerOptions)

You can also deactivate and remove a location marker that was previously added to the map.

tomTomMap.disableLocationMarker()

The location marker is displayed as shown below.

Chevron

Next steps

Since you have learned how to show user locations, here are recommendations for the next steps: