dioxus_leaflet/types/
map_options.rs1use serde::{Deserialize, Serialize};
2use super::{TileLayer, LeafletResources};
3
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct MapOptions {
7 pub zoom_control: bool,
8 pub scroll_wheel_zoom: bool,
9 pub double_click_zoom: bool,
10 pub touch_zoom: bool,
11 pub dragging: bool,
12 pub keyboard: bool,
13 pub attribution_control: bool,
14 pub tile_layer: TileLayer,
15 pub leaflet_resources: LeafletResources,
16}
17
18impl Default for MapOptions {
19 fn default() -> Self {
20 Self {
21 zoom_control: true,
22 scroll_wheel_zoom: true,
23 double_click_zoom: true,
24 touch_zoom: true,
25 dragging: true,
26 keyboard: true,
27 attribution_control: true,
28 tile_layer: TileLayer::default(),
29 leaflet_resources: LeafletResources::default(),
30 }
31 }
32}
33
34impl MapOptions {
35 pub fn minimal() -> Self {
37 Self {
38 zoom_control: false,
39 scroll_wheel_zoom: false,
40 double_click_zoom: false,
41 touch_zoom: false,
42 dragging: false,
43 keyboard: false,
44 attribution_control: false,
45 tile_layer: TileLayer::default(),
46 leaflet_resources: LeafletResources::default(),
47 }
48 }
49
50 pub fn with_zoom_control(mut self, enabled: bool) -> Self {
52 self.zoom_control = enabled;
53 self
54 }
55
56 pub fn with_scroll_wheel_zoom(mut self, enabled: bool) -> Self {
58 self.scroll_wheel_zoom = enabled;
59 self
60 }
61
62 pub fn with_double_click_zoom(mut self, enabled: bool) -> Self {
64 self.double_click_zoom = enabled;
65 self
66 }
67
68 pub fn with_touch_zoom(mut self, enabled: bool) -> Self {
70 self.touch_zoom = enabled;
71 self
72 }
73
74 pub fn with_dragging(mut self, enabled: bool) -> Self {
76 self.dragging = enabled;
77 self
78 }
79
80 pub fn with_keyboard(mut self, enabled: bool) -> Self {
82 self.keyboard = enabled;
83 self
84 }
85
86 pub fn with_attribution_control(mut self, enabled: bool) -> Self {
88 self.attribution_control = enabled;
89 self
90 }
91
92 pub fn with_tile_layer(mut self, tile_layer: TileLayer) -> Self {
94 self.tile_layer = tile_layer;
95 self
96 }
97
98 pub fn with_leaflet_resources(mut self, resources: LeafletResources) -> Self {
100 self.leaflet_resources = resources;
101 self
102 }
103}