pub struct Geolocation<R: Runtime>(/* private fields */);Expand description
Access to the geolocation APIs.
Implementations§
Source§impl<R: Runtime> Geolocation<R>
impl<R: Runtime> Geolocation<R>
Sourcepub fn get_current_position(
&self,
options: Option<PositionOptions>,
) -> Result<Position>
pub fn get_current_position( &self, options: Option<PositionOptions>, ) -> Result<Position>
Returns the device’s current Position. On Android this returns the last known location immediately if it is still within maximum_age, otherwise it requests a fresh reading. Errors if location services are disabled or the required permission was not granted.
Sourcepub fn watch_position<F: Fn(WatchEvent) + Send + Sync + 'static>(
&self,
options: PositionOptions,
callback: F,
) -> Result<u32>
pub fn watch_position<F: Fn(WatchEvent) + Send + Sync + 'static>( &self, options: PositionOptions, callback: F, ) -> Result<u32>
Register a position watcher. This method returns an id to use in clear_watch.
Sourcepub fn clear_watch(&self, channel_id: u32) -> Result<()>
pub fn clear_watch(&self, channel_id: u32) -> Result<()>
Removes the position watcher registered with the given channel_id, as returned by Self::watch_position. Stops the platform location updates once no watcher remains.
Sourcepub fn check_permissions(&self) -> Result<PermissionStatus>
pub fn check_permissions(&self) -> Result<PermissionStatus>
Returns the current PermissionStatus for the geolocation APIs. Errors if location services are disabled on the device.
Sourcepub fn request_permissions(
&self,
permissions: Option<Vec<PermissionType>>,
) -> Result<PermissionStatus>
pub fn request_permissions( &self, permissions: Option<Vec<PermissionType>>, ) -> Result<PermissionStatus>
Requests the given permissions (or all of them when None) and returns the resulting PermissionStatus. Errors if location services are disabled on the device.