dioxus_leaflet/types/
tile_layer.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct TileLayer {
6 pub url: String,
7 pub attribution: String,
8 pub max_zoom: u8,
9 pub subdomains: Vec<String>,
10}
11
12impl TileLayer {
13 pub fn openstreetmap() -> Self {
15 Self {
16 url: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png".to_string(),
17 attribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors".to_string(),
18 max_zoom: 19,
19 subdomains: vec!["a".to_string(), "b".to_string(), "c".to_string()],
20 }
21 }
22
23 pub fn satellite() -> Self {
25 Self {
26 url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}".to_string(),
27 attribution: "Tiles © Esri".to_string(),
28 max_zoom: 18,
29 subdomains: vec![],
30 }
31 }
32}
33
34impl Default for TileLayer {
35 fn default() -> Self {
36 Self::openstreetmap()
37 }
38}