Dioxus Geolocation
Geolocation utilities and hooks for Dioxus.
Supports
- Web
- Windows
- Mac
- Linux
- Android
- iOs
Usage
Add dioxus-sdk-geolocation to your Cargo.toml:
[]
= "0.1"
Example:
use *;
use ;
Geolocation utilities and hooks for Dioxus.
Add dioxus-sdk-geolocation to your Cargo.toml:
[dependencies]
dioxus-sdk-geolocation = "0.1"
Example:
use dioxus::prelude::*;
use dioxus_sdk_geolocation::{
init_geolocator, use_geolocation, PowerMode
};
#[component]
fn App() -> Element {
let geolocator = init_geolocator(PowerMode::High).unwrap();
let coords = use_geolocation();
match coords {
Ok(coords) => {
rsx!( p { "Latitude: {coords.latitude} | Longitude: {coords.longitude}" } )
}
Err(Error::NotInitialized) => {
rsx!( p { "Initializing..." } )
}
Err(e) => {
rsx!( p { "An error occurred {e}" } )
}
}
}