Skip to main content

dioxus_maplibre/handle/
controls.rs

1//! Control-related MapHandle methods.
2
3use super::{MapHandle, control_position_str};
4use crate::options::ControlPosition;
5
6impl MapHandle {
7    /// Add a navigation control (zoom +/- buttons and compass)
8    pub fn add_navigation_control(&self, position: ControlPosition) {
9        self.fire_and_forget(|| {
10            let pos = control_position_str(position);
11            crate::interop::add_navigation_control_js(&self.map_id, pos)
12        });
13    }
14
15    /// Remove a navigation control.
16    pub fn remove_navigation_control(&self, position: ControlPosition) {
17        self.fire_and_forget(|| {
18            let pos = control_position_str(position);
19            crate::interop::remove_navigation_control_js(&self.map_id, pos)
20        });
21    }
22
23    /// Add a geolocate control.
24    pub fn add_geolocate_control(&self, position: ControlPosition) {
25        self.fire_and_forget(|| {
26            let pos = control_position_str(position);
27            crate::interop::add_geolocate_control_js(&self.map_id, pos)
28        });
29    }
30
31    /// Remove a geolocate control.
32    pub fn remove_geolocate_control(&self, position: ControlPosition) {
33        self.fire_and_forget(|| {
34            let pos = control_position_str(position);
35            crate::interop::remove_geolocate_control_js(&self.map_id, pos)
36        });
37    }
38
39    /// Add a scale control.
40    pub fn add_scale_control(&self, position: ControlPosition) {
41        self.fire_and_forget(|| {
42            let pos = control_position_str(position);
43            crate::interop::add_scale_control_js(&self.map_id, pos)
44        });
45    }
46
47    /// Remove a scale control.
48    pub fn remove_scale_control(&self, position: ControlPosition) {
49        self.fire_and_forget(|| {
50            let pos = control_position_str(position);
51            crate::interop::remove_scale_control_js(&self.map_id, pos)
52        });
53    }
54
55    /// Add a fullscreen control.
56    pub fn add_fullscreen_control(&self, position: ControlPosition) {
57        self.fire_and_forget(|| {
58            let pos = control_position_str(position);
59            crate::interop::add_fullscreen_control_js(&self.map_id, pos)
60        });
61    }
62
63    /// Remove a fullscreen control.
64    pub fn remove_fullscreen_control(&self, position: ControlPosition) {
65        self.fire_and_forget(|| {
66            let pos = control_position_str(position);
67            crate::interop::remove_fullscreen_control_js(&self.map_id, pos)
68        });
69    }
70
71    /// Add an attribution control.
72    pub fn add_attribution_control(&self, position: ControlPosition) {
73        self.fire_and_forget(|| {
74            let pos = control_position_str(position);
75            crate::interop::add_attribution_control_js(&self.map_id, pos)
76        });
77    }
78
79    /// Remove an attribution control.
80    pub fn remove_attribution_control(&self, position: ControlPosition) {
81        self.fire_and_forget(|| {
82            let pos = control_position_str(position);
83            crate::interop::remove_attribution_control_js(&self.map_id, pos)
84        });
85    }
86}