sdk-common / com.tomtom.online.sdk.location / LocationSource

LocationSource

interface LocationSource

Interface that provides location data, typically to a TomtomMap object. A TomtomMap has a built-in location provider, however, it can be replaced with custom one that implements this interface.

Functions

activate

abstract fun activate(): Unit

Activates the provider. The provider will notify the listener periodically, until the user calls deactivate().

addLocationUpdateListener

abstract fun addLocationUpdateListener(locationUpdateListener: LocationUpdateListener!): Unit

Adds location update listener.

deactivate

abstract fun deactivate(): Unit

Deactivates this provider. The provider does not send any location notifications.

getAllLocationUpdateListeners

abstract fun getAllLocationUpdateListeners(): MutableList<LocationUpdateListener!>!

Obtains the list of all added location update listeners.

getLastKnownLocation

abstract fun getLastKnownLocation(): Location?

Last valid location of the user. The value can be null.

onLocationChanged

abstract fun onLocationChanged(location: Location!): Unit

Is called when new location is found by the corresponding location source provider.

removeAllLocationUpdateListeners

abstract fun removeAllLocationUpdateListeners(): Unit

Removes all location update listeners.

removeLocationUpdateListener

abstract fun removeLocationUpdateListener(locationUpdateListener: LocationUpdateListener!): Unit

Removes location update listener.

Inheritors

AbstractLocationSource

abstract class AbstractLocationSource : LocationSource, LocationListener

Base class for all LocationSources. It contains the listeners list and propagate onLocationChange events to added listeners.

FusedLocationSource

open class FusedLocationSource : LocationCallback, LocationSource, ConnectionCallbacks, OnConnectionFailedListener, Contextable

Default location source implementation. It is based on FusedLocationService provided by Google. When no custom location source is provided, map is using it to get the user location. It uses {LocationUpdateListener} to notify about new location updates.