- Direct Known Subclasses:
 NmeaLocationDataSource,SimulatedLocationDataSource
MapView.locationDisplayProperty().
 
 This is a base class for a number of different location data sources, such as NmeaLocationDataSource and
 SimulatedLocationDataSource. Call
 startAsync() to receive location updates and display the current location using the
 MapView.locationDisplayProperty().
- Since:
 - 100.9.0
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classAn event that is invoked whenthe error propertychanges.static interfaceThe listener interface for receivingerror changed eventsfrom a LocationDataSource.final classAn event representing the change of the heading of a LocationDataSource.static interfaceThe listener interface for receiving heading changed events from a LocationDataSource.static classA location update provided by a LocationDataSource, consisting primarily of aPointrepresenting a geographical location, and attributes of location change such as the course (direction of travel), and the velocity (speed of location change).final classAn event representing the change of the location of a LocationDataSource.static interfaceThe listener interface for receiving location changed events from a LocationDataSource.static enumThe enumeration of possible LocationDataSource statuses.final classAn event representing the change of the status of a LocationDataSource.static interfaceThe listener interface for receiving status changed events from a LocationDataSource. - 
Constructor Summary
ConstructorsConstructorDescriptionCreates a default LocationDataSource, and sets up the status changed listeners. - 
Method Summary
Modifier and TypeMethodDescriptionfinal voidRegisters the given listener to be called when theerror propertyhas changed.final voidRegisters the given listener to be called when the heading has changed.final voidRegisters the given listener to be called when the location has changed.final voidRegisters the given listener to be called when the status has changed.final ThrowablegetError()Gets an error that describes a problem encountered while starting or running theLocationDataSource.Gets the current status of the location data source.protected abstract voidonStart()Called fromstartAsync().protected final voidonStartCompleted(Throwable throwable) Sets the result status of the starting process, and any error generated during it.protected abstract voidonStop()Called from thestopAsync()method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.final booleanUnregisters the given listener that was previously added usingaddErrorChangedListener(ErrorChangedListener).final booleanUnregisters the given listener that was previously added usingaddHeadingChangedListener(HeadingChangedListener).final booleanUnregisters the given listener that was previously added usingaddLocationChangedListener(LocationChangedListener).final booleanUnregisters the given listener that was previously added usingaddStatusChangedListener(StatusChangedListener).protected final voidSets the last known Location, which will be displayed as soon as the data source has been started, until a new location update is received.final ListenableFuture<Void> Asynchronously initializes the location data source and prepares to begin receiving location updates.final ListenableFuture<Void> Stops the location data source asynchronously.protected final voidupdateHeading(double heading) Updates the current heading angle.protected final voidupdateLocation(LocationDataSource.Location location) Updates the position of the current location. 
- 
Constructor Details
- 
LocationDataSource
public LocationDataSource()Creates a default LocationDataSource, and sets up the status changed listeners. This method should be called by the subclass constructor before performing other work.- Since:
 - 100.9.0
 
 
 - 
 - 
Method Details
- 
startAsync
Asynchronously initializes the location data source and prepares to begin receiving location updates. Calls theonStart()method of a subclass.- Returns:
 - a ListenableFuture indicating when the LocationDataSource has started.
 - Since:
 - 100.9.0
 
 - 
addLocationChangedListener
Registers the given listener to be called when the location has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
 listener- a listener to be called when the location has changed- Throws:
 IllegalArgumentException- if listener is null- Since:
 - 100.9.0
 - See Also:
 
 - 
removeLocationChangedListener
public final boolean removeLocationChangedListener(LocationDataSource.LocationChangedListener listener) Unregisters the given listener that was previously added usingaddLocationChangedListener(LocationChangedListener).- Parameters:
 listener- the listener to unregister- Returns:
 - true if the listener was removed successfully; false otherwise
 - Since:
 - 100.9.0
 
 - 
addHeadingChangedListener
Registers the given listener to be called when the heading has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
 listener- a listener to be called when the heading has changed- Throws:
 IllegalArgumentException- if listener is null- Since:
 - 100.9.0
 - See Also:
 
 - 
removeHeadingChangedListener
public final boolean removeHeadingChangedListener(LocationDataSource.HeadingChangedListener listener) Unregisters the given listener that was previously added usingaddHeadingChangedListener(HeadingChangedListener).- Parameters:
 listener- the listener to unregister- Returns:
 - true if the listener was removed successfully; false otherwise
 - Since:
 - 100.9.0
 
 - 
addStatusChangedListener
Registers the given listener to be called when the status has changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
 listener- a listener to be called when the status has changed- Throws:
 IllegalArgumentException- if listener is null- Since:
 - 100.9.0
 - See Also:
 
 - 
removeStatusChangedListener
Unregisters the given listener that was previously added usingaddStatusChangedListener(StatusChangedListener).- Parameters:
 listener- the listener to unregister- Returns:
 - true if the listener was removed successfully; false otherwise
 - Since:
 - 100.9.0
 
 - 
addErrorChangedListener
Registers the given listener to be called when theerror propertyhas changed.This listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- Parameters:
 listener- a listener to be called when the error has changed- Throws:
 IllegalArgumentException- if listener is null- Since:
 - 100.14.0
 - See Also:
 
 - 
removeErrorChangedListener
Unregisters the given listener that was previously added usingaddErrorChangedListener(ErrorChangedListener).- Parameters:
 listener- the listener to unregister- Returns:
 - true if the listener was removed successfully; false otherwise
 - Since:
 - 100.14.0
 
 - 
getError
Gets an error that describes a problem encountered while starting or running theLocationDataSource.This property is used to notify the user about errors that occur in
LocationDataSource. Such errors are critical forLocationDataSourceand will cause it to stop. IfLocationDataSourcecannot be started, or it stopped after a successful start, this property will store information related to what causedLocationDataSourceto stop.- Returns:
 - an error that describes a problem encountered while starting or running the LocationDataSource, or null if none
 - Since:
 - 100.9.0
 
 - 
getStatus
Gets the current status of the location data source.The status indicates if the location data source is starting, started, stopping, stopped, and has failed to start.
- Returns:
 - the current status of the LocationDataSource
 - Since:
 - 100.14.0
 
 - 
onStartCompleted
Sets the result status of the starting process, and any error generated during it. This method must be called by the subclass once the location data source has finished its starting process.- Parameters:
 throwable- the error generated during the starting process, or null if it started successfully- Since:
 - 100.9.0
 
 - 
setLastKnownLocation
Sets the last known Location, which will be displayed as soon as the data source has been started, until a new location update is received.The last known location may not accurately represent the true current location, but indicates to the user that the LocationDataSource is waiting for updated location data. It will be displayed using the LocationDisplay.getAcquiringSymbol().
- Parameters:
 location- the last known location
 - 
onStart
protected abstract void onStart()Called fromstartAsync(). Subclasses should implement this method to prepare for starting the data source. TheonStartCompleted(Throwable)method must be called by the subclass once the location data source has finished its starting process.- Since:
 - 100.9.0
 
 - 
stopAsync
Stops the location data source asynchronously. This method will call theonStop()method implementation of the subclass.- Returns:
 - a ListenableFuture indicating when the LocationDataSource has stopped.
 - Since:
 - 100.14.0
 
 - 
onStop
protected abstract void onStop()Called from thestopAsync()method, subclasses should perform any necessary clean-up in this method; for example, stop streaming the location data, release resources, and so on.- Since:
 - 100.9.0
 
 - 
updateHeading
protected final void updateHeading(double heading) Updates the current heading angle.Called when the data source has a new heading value. The LocationDisplay.getHeading() associated with this LocationDataSource will be updated with this value and any HeadingChangedListener added will also be notified.
- Parameters:
 heading- the heading angle, in degrees clockwise, relative to north- Since:
 - 100.9.0
 
 - 
updateLocation
Updates the position of the current location.Called when the data source has new location information. The LocationDisplay.getLocation() associated with this LocationDataSource will be updated with this value and any LocationChangedListener added will also be notified.
- Parameters:
 location- the updated Location- Since:
 - 100.9.0
 - See Also:
 
 
 -