Skip to content

Commit 67be144

Browse files
haexhubhaex-space
andauthored
feat(map): satellite layer toggle (#24)
* feat(map): add satellite layer toggle (Esri World Imagery) * feat(map): use OSM.de tiles for German labels + add labeled satellite layer --------- Co-authored-by: haex <mail@haex.space>
1 parent 922274d commit 67be144

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

components/AuctionDetailMap.client.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,29 @@ onMounted(async () => {
3232
await nextTick()
3333
if (!mapEl.value) return
3434
map = L.map(mapEl.value, { scrollWheelZoom: false }).setView([props.lat, props.lng], 14)
35-
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
36-
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
37-
maxZoom: 19,
35+
const streets = L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {
36+
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> Deutschland',
37+
maxZoom: 18,
3838
}).addTo(map)
39+
const esriImagery = L.tileLayer(
40+
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
41+
{
42+
attribution: 'Tiles &copy; Esri &mdash; Source: Esri, Maxar, Earthstar Geographics',
43+
maxZoom: 19,
44+
},
45+
)
46+
const deLabels = L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {
47+
maxZoom: 18,
48+
opacity: 0.55,
49+
})
50+
const satelliteLabeled = L.layerGroup([esriImagery, deLabels])
51+
L.control
52+
.layers(
53+
{ Straße: streets, 'Satellit + Beschriftung': satelliteLabeled, 'Satellit (nur Bild)': esriImagery },
54+
undefined,
55+
{ position: 'topright' },
56+
)
57+
.addTo(map)
3958
const marker = L.marker([props.lat, props.lng], { icon: markerIcon })
4059
if (props.label) marker.bindTooltip(props.label)
4160
marker.addTo(map)

components/AuctionMap.client.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,29 @@ function refreshMarkers(): void {
114114
onMounted(() => {
115115
if (!mapEl.value) return
116116
map = L.map(mapEl.value, { scrollWheelZoom: true }).setView(GERMANY_CENTER, 6)
117-
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
118-
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
119-
maxZoom: 19,
117+
const streets = L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {
118+
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> Deutschland',
119+
maxZoom: 18,
120120
}).addTo(map)
121+
const esriImagery = L.tileLayer(
122+
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
123+
{
124+
attribution: 'Tiles &copy; Esri &mdash; Source: Esri, Maxar, Earthstar Geographics',
125+
maxZoom: 19,
126+
},
127+
)
128+
const deLabels = L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png', {
129+
maxZoom: 18,
130+
opacity: 0.55,
131+
})
132+
const satelliteLabeled = L.layerGroup([esriImagery, deLabels])
133+
L.control
134+
.layers(
135+
{ Straße: streets, 'Satellit + Beschriftung': satelliteLabeled, 'Satellit (nur Bild)': esriImagery },
136+
undefined,
137+
{ position: 'topright' },
138+
)
139+
.addTo(map)
121140
markersLayer = L.layerGroup().addTo(map)
122141
refreshMarkers()
123142
})

0 commit comments

Comments
 (0)