Package arez.dom
Class GeoPosition
java.lang.Object
arez.dom.GeoPosition
@ArezComponent(requireId=DISABLE,
disposeNotifier=DISABLE)
public abstract class GeoPosition
extends Object
A component that exposes the current geo position as an observable property. This component relies on the
underlying Geolocation API and
it's usage is restricted in the same way as the underlying API (i.e. it is only available in secure contexts
and it asks user permission before providing data.).
EventDrivenValue<Window, Integer> innerWidth = EventDrivenValue.create( window, "resize", () -> window.innerWidth )
It is important that the code not add a listener to the underlying event source until there is an
observer accessing the "value"
observable defined by the EventDrivenValue class. The first
observer that observes the observable will result in an event listener being added to the event source
and this listener will not be removed until there is no observers left observing the value. This means
that a component that is not being used has very little overhead.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic GeoPosition
create()
Create the GeoPosition component.Return the error message reported by the geolocation API when position could not be loaded else null.Return an immutable representation of the current position.int
Return the status indicating whether the position is available.
-
Method Details
-
create
Create the GeoPosition component.- Returns:
- the newly created GeoPosition component.
-
getPosition
Return an immutable representation of the current position. This will be null unlessgetStatus()
has returned aGeoPosition.Status.POSITION_LOADED
value.- Returns:
- the current position as reported by the geolocation API.
-
getStatus
Return the status indicating whether the position is available. It will be one of the values provided byGeoPosition.Status
.- Returns:
- the status of the position data.
-
getErrorMessage
Return the error message reported by the geolocation API when position could not be loaded else null.- Returns:
- the error message if any.
-