vue-mapbox
vue-mapbox copied to clipboard
How to reload layers after style change?
When map style is changed, layers are removed (even with clearSource: false option) and the new style loads without the previous layer. Geojson features do not display, despite their sources remaining.
mapbox-gl.js?e192:29 Error: The layer 'my-layer' does not exist in the map's style and cannot be queried for features.
Should there be a layer method for reload? Only remove, and move exist currently.
In case anyone comes across this problem, my workaround:
if(!this.map.getLayer('my-layer-name')){
this.map.addLayer({
...this.myLayer,
id: 'my-layer-name',
source: this.geojsonSource
})
}