dioxus_maplibre/handle/
markers.rs1#![allow(clippy::needless_pass_by_value)]
3
4use super::MapHandle;
5use crate::options::MarkerOptions;
6use crate::types::LatLng;
7
8impl MapHandle {
9 pub fn add_marker(&self, id: &str, position: LatLng, options: MarkerOptions) {
11 self.fire_and_forget(|| {
12 let json = serde_json::to_string(&options).unwrap_or_default();
13 crate::interop::add_marker_js(&self.map_id, id, position.lat, position.lng, &json)
14 });
15 }
16
17 pub fn remove_marker(&self, id: &str) {
19 self.fire_and_forget(|| crate::interop::remove_marker_js(&self.map_id, id));
20 }
21
22 pub fn update_marker_position(&self, id: &str, position: LatLng) {
24 self.fire_and_forget(|| {
25 crate::interop::update_marker_position_js(&self.map_id, id, position.lat, position.lng)
26 });
27 }
28}