Closed JWDobken closed 6 years ago
Apparently I did not understood the concept of style correctly; and the above is actually the expected behavior and all layers should be added again after the style has changed.
is there a listener when to style is set? Like styleLoaded
?
styleLoaded (map) {
this.addLayers()
},
Now I use:
watch: {
baseMapStyle: function (val) {
this.map.setStyle(val)
this.map.on('style.load', () => {
const waiting = () => {
if (!this.map.isStyleLoaded()) {
setTimeout(waiting, 200)
} else {
this.loadLayers()
}
}
waiting()
})
}
}
COTCHA: @map-styledata="loadLayers"
This repo is awesome
I have a vue button to change the style, not fully sure if this is the correct way to implement. But the problem is that my layers disappear when the style is changed.
the
script
toggles thebaseMapStyle
value with a watch function: