Package org.vaadin.firitin.geolocation
Class Geolocation
java.lang.Object
org.vaadin.firitin.geolocation.Geolocation
Deprecated, for removal: This API element is subject to removal in a future version.
A helper class to detect the geographical position of the end users.
This class uses the Geolocation API in the browser to detect the position of the user. The API mimics the JS counterpart.
Note that the availability and quality of the position data can vary a lot. Users can decline the geolocation request in the browser altogether, but developers can also affect the settings using GeolocationOptions.
- Author:
- mstahv
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDeprecated, for removal: This API element is subject to removal in a future version.static interfaceDeprecated, for removal: This API element is subject to removal in a future version. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Deprecated, for removal: This API element is subject to removal in a future version.Stops polling the listeners with the new geolocation data.static voidgetCurrentPosition(com.vaadin.flow.component.UI ui, Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.static voidgetCurrentPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.static voidgetCurrentPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.static GeolocationwatchPosition(com.vaadin.flow.component.UI ui, Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.static GeolocationwatchPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.static GeolocationwatchPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.
-
Constructor Details
-
Geolocation
public Geolocation()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
watchPosition
public static Geolocation watchPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.- Parameters:
listener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)- Returns:
- a Geolocation instance that can be used to cancel requesting the data
-
watchPosition
public static Geolocation watchPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.- Parameters:
listener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)options- options for the geolocation request- Returns:
- a Geolocation instance that can be used to cancel requesting the data
-
watchPosition
public static Geolocation watchPosition(com.vaadin.flow.component.UI ui, Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Starts to repeatedly watch the geolocation of the device and notifies listener with the data.- Parameters:
ui- the UI in which context the geolocation request is to be executedlistener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)options- options for the geolocation request- Returns:
- a Geolocation instance that can be used to cancel requesting the data
-
getCurrentPosition
public static void getCurrentPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.- Parameters:
listener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)options- options for the geolocation request
-
getCurrentPosition
public static void getCurrentPosition(com.vaadin.flow.component.UI ui, Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener, GeolocationOptions options) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.- Parameters:
ui- the UI in which context the geolocation request is to be executedlistener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)options- options for the geolocation request
-
getCurrentPosition
public static void getCurrentPosition(Geolocation.UpdateListener listener, Geolocation.ErrorListener errorListener) Deprecated, for removal: This API element is subject to removal in a future version.Determines the device's current location once and notifies listener with the data.- Parameters:
listener- the listener called on succesful geolocation requesterrorListener- the listener called in case the request failed (e.g. user declined the request in the browser)
-
cancel
public void cancel()Deprecated, for removal: This API element is subject to removal in a future version.Stops polling the listeners with the new geolocation data.
-
com.vaadin.flow.component.geolocation.Geolocation. Prefer it:Geolocation.watchPosition(component)returns aGeolocationWatcherthat is bound to the component and auto-stopped on detach (no manualcancel()), and it offers a one-shotgetPosition(...), aGeolocationOptions.builder()and Signal-based reads. Note the migration is not drop-in: position data is exposed as a record (position.coords().longitude()) instead of getters.