Skip to main content

dioxus_leaflet/types/
map_position.rs

1use crate::LatLng;
2use serde::{Deserialize, Serialize};
3
4/// Represents a geographical position with zoom level
5#[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
6pub struct MapPosition {
7    pub coordinates: LatLng,
8    pub zoom: f64,
9}
10
11impl MapPosition {
12    /// Creates a new MapPosition
13    pub const fn new(lat: f64, lng: f64, zoom: f64) -> Self {
14        Self {
15            coordinates: LatLng::new(lat, lng),
16            zoom,
17        }
18    }
19}
20
21impl Default for MapPosition {
22    fn default() -> Self {
23        Self::new(51.505, -0.09, 13.0)
24    }
25}