Fix error when using non-swisstopo maps again

pull/27/head
Manuel Kasper 2025-04-22 17:25:10 +02:00
rodzic 8c461a9332
commit bc7118d52e
1 zmienionych plików z 65 dodań i 63 usunięć

Wyświetl plik

@ -88,72 +88,74 @@ export default {
} }
}) })
if (this.mapOptions['snow_depth']) { if (this.mapTypes[this.mapType].snow_depth) {
if (!map.getSource('snowcover')) { if (this.mapOptions['snow_depth']) {
map.addSource('snowcover', { if (!map.getSource('snowcover')) {
type: 'geojson', map.addSource('snowcover', {
data: 'https://snow-maps-hs.slf.ch/public/hs/map/HS1D-v2/current/geojson' type: 'geojson',
}) data: 'https://snow-maps-hs.slf.ch/public/hs/map/HS1D-v2/current/geojson'
let snowcoverPattern = new Image()
snowcoverPattern.src = require('../assets/partial-snowcover-dots.png')
snowcoverPattern.onload = () => {
map.addImage('partial-snowcover-pattern', snowcoverPattern, {
pixelRatio: 2
}) })
map.addLayer({ let snowcoverPattern = new Image()
id: 'snowcover-partial-background', snowcoverPattern.src = require('../assets/partial-snowcover-dots.png')
type: 'fill', snowcoverPattern.onload = () => {
source: 'snowcover', map.addImage('partial-snowcover-pattern', snowcoverPattern, {
filter: ['all', ['get', 'partialSnowCover'], ['==', ['get', 'value'], 1]], pixelRatio: 2
layout: { })
'fill-sort-key': ['get', 'zIndex'] map.addLayer({
}, id: 'snowcover-partial-background',
paint: { type: 'fill',
'fill-color': ['get', 'fill'], source: 'snowcover',
'fill-opacity': 1.0 filter: ['all', ['get', 'partialSnowCover'], ['==', ['get', 'value'], 1]],
} layout: {
}, 'scree_z17') 'fill-sort-key': ['get', 'zIndex']
map.addLayer({ },
id: 'snowcover-partial', paint: {
type: 'fill', 'fill-color': ['get', 'fill'],
source: 'snowcover', 'fill-opacity': 1.0
filter: ['all', ['get', 'partialSnowCover'], ['==', ['get', 'value'], 1]], }
layout: { }, 'scree_z17')
'fill-sort-key': ['get', 'zIndex'] map.addLayer({
}, id: 'snowcover-partial',
paint: { type: 'fill',
'fill-pattern': 'partial-snowcover-pattern', source: 'snowcover',
'fill-opacity': 0.2 filter: ['all', ['get', 'partialSnowCover'], ['==', ['get', 'value'], 1]],
} layout: {
}, 'scree_z17') 'fill-sort-key': ['get', 'zIndex']
map.addLayer({ },
id: 'snowcover', paint: {
type: 'fill', 'fill-pattern': 'partial-snowcover-pattern',
source: 'snowcover', 'fill-opacity': 0.2
filter: ['any', ['!', ['get', 'partialSnowCover']], ['>', ['get', 'value'], 1]], }
layout: { }, 'scree_z17')
'fill-sort-key': ['get', 'zIndex'] map.addLayer({
}, id: 'snowcover',
paint: { type: 'fill',
'fill-color': ['get', 'fill'], source: 'snowcover',
'fill-opacity': 1.0 filter: ['any', ['!', ['get', 'partialSnowCover']], ['>', ['get', 'value'], 1]],
} layout: {
}, 'scree_z17') 'fill-sort-key': ['get', 'zIndex']
},
paint: {
'fill-color': ['get', 'fill'],
'fill-opacity': 1.0
}
}, 'scree_z17')
}
} else {
map.setLayoutProperty('snowcover-partial-background', 'visibility', 'visible')
map.setLayoutProperty('snowcover-partial', 'visibility', 'visible')
map.setLayoutProperty('snowcover', 'visibility', 'visible')
} }
map.setLayoutProperty('water_polygon', 'visibility', 'none')
} else { } else {
map.setLayoutProperty('snowcover-partial-background', 'visibility', 'visible') if (map.getLayer('snowcover')) {
map.setLayoutProperty('snowcover-partial', 'visibility', 'visible') map.setLayoutProperty('snowcover-partial-background', 'visibility', 'none')
map.setLayoutProperty('snowcover', 'visibility', 'visible') map.setLayoutProperty('snowcover-partial', 'visibility', 'none')
} map.setLayoutProperty('snowcover', 'visibility', 'none')
map.setLayoutProperty('water_polygon', 'visibility', 'none') }
} else { if (map.getLayer('water_polygon')) {
if (map.getLayer('snowcover')) { map.setLayoutProperty('water_polygon', 'visibility', 'visible')
map.setLayoutProperty('snowcover-partial-background', 'visibility', 'none') }
map.setLayoutProperty('snowcover-partial', 'visibility', 'none')
map.setLayoutProperty('snowcover', 'visibility', 'none')
}
if (map.getLayer('water_polygon')) {
map.setLayoutProperty('water_polygon', 'visibility', 'visible')
} }
} }
} }