mod controls;
mod escape_hatch;
mod feature_state;
mod getters;
mod images;
mod layer_events;
mod layers;
mod markers;
mod navigation;
mod padding;
mod popups;
mod queries;
mod sources;
mod style;
mod terrain_atmosphere;
use crate::options::ControlPosition;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MapHandle {
map_id: String,
}
impl MapHandle {
#[allow(dead_code)] pub(crate) fn new(map_id: String) -> Self {
Self { map_id }
}
pub fn map_id(&self) -> &str {
&self.map_id
}
#[cfg(target_arch = "wasm32")]
pub(crate) fn fire_and_forget(&self, js_fn: impl FnOnce() -> String) {
let js = js_fn();
dioxus::prelude::spawn(async move {
let _ = document::eval(&js).await;
});
}
#[allow(clippy::unused_self)]
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn fire_and_forget(&self, _js_fn: impl FnOnce() -> String) {
}
#[cfg(target_arch = "wasm32")]
pub(crate) fn eval_raw(&self, js: &str) {
let js = js.to_string();
dioxus::prelude::spawn(async move {
let _ = document::eval(&js).await;
});
}
#[allow(clippy::unused_self)]
#[cfg(not(target_arch = "wasm32"))]
pub(crate) fn eval_raw(&self, _js: &str) {}
}
#[cfg(target_arch = "wasm32")]
use dioxus::prelude::document;
pub(crate) fn control_position_str(pos: ControlPosition) -> &'static str {
match pos {
ControlPosition::TopLeft => "top-left",
ControlPosition::TopRight => "top-right",
ControlPosition::BottomLeft => "bottom-left",
ControlPosition::BottomRight => "bottom-right",
}
}