public interface PositionService
The PositionService provides a read-only position property
that will be updated at regular intervals by the underlying platform implementation.
A user of the PositionService can listen to changes of the position by registering a
ChangeListener
to the
position property
.
Example
Services.get(PositionService.class).ifPresent(service -> {
Position position = service.getPosition();
System.out.printf("Current position: %.5f, %.5f",
position.getLatitude(), position.getLongitude());
});
Android Configuration
The permission android.permission.ACCESS_FINE_LOCATION
needs to be added.
<manifest ...>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
...
</manifest>
iOS Configuration
The following keys are required:
<key>NSLocationUsageDescription</key>
<string>Reason to use Location Service (iOS 6+)</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Reason to use Location Service (iOS 8+)</string>
Type | Property and Description |
---|---|
javafx.beans.property.ReadOnlyObjectProperty<Position> |
position
A read-only property containing information about the device's current
location on earth.
|
Modifier and Type | Method and Description |
---|---|
Position |
getPosition()
The current position on earth of the device.
|
javafx.beans.property.ReadOnlyObjectProperty<Position> |
positionProperty()
A read-only property containing information about the device's current
location on earth.
|
javafx.beans.property.ReadOnlyObjectProperty<Position> positionProperty
null
object
when the position of the device could be determined.getPosition()
javafx.beans.property.ReadOnlyObjectProperty<Position> positionProperty()
null
object
when the position of the device could be determined.getPosition()
Position getPosition()
null
when the position of the device could not be determined, for instance
when the GPS has been turned off.