mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-04 17:32:56 +00:00
refresh layers after style change
This commit is contained in:
@@ -5,25 +5,31 @@
|
||||
|
||||
export let file: GPXFile;
|
||||
|
||||
$: if ($map) {
|
||||
$map.on('load', () => {
|
||||
function addGPXLayer() {
|
||||
if (!$map.getSource('gpx')) {
|
||||
$map.addSource('gpx', {
|
||||
type: 'geojson',
|
||||
data: file.toGeoJSON()
|
||||
});
|
||||
$map.addLayer({
|
||||
id: 'gpx',
|
||||
type: 'line',
|
||||
source: 'gpx',
|
||||
layout: {
|
||||
'line-join': 'round',
|
||||
'line-cap': 'round'
|
||||
},
|
||||
paint: {
|
||||
'line-color': '#888',
|
||||
'line-width': 8
|
||||
}
|
||||
});
|
||||
}
|
||||
$map.addLayer({
|
||||
id: 'gpx',
|
||||
type: 'line',
|
||||
source: 'gpx',
|
||||
layout: {
|
||||
'line-join': 'round',
|
||||
'line-cap': 'round'
|
||||
},
|
||||
paint: {
|
||||
'line-color': '#888',
|
||||
'line-width': 8
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$: if ($map) {
|
||||
$map.on('style.load', () => {
|
||||
addGPXLayer();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user