Skip to content

Commit

Permalink
fix: keep isochrone across style changing #359
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Oct 22, 2024
1 parent ceebdc9 commit c05a4ea
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion components/Map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,25 @@ export default defineNuxtComponent({
this.style = style
this.doWithMap(() => {
// Use no diff mode to avoid issue with added layers
this.map!.setStyle(style, { diff: false })
this.map!.setStyle(style, {
diff: false,
transformStyle: (previousStyle, nextStyle) => {
if (previousStyle?.sources.isochrone) {
style = {
...nextStyle,
sources: {
...nextStyle.sources,
isochrone: previousStyle.sources.isochrone,
},
layers: [
...nextStyle.layers,
...previousStyle.layers.filter(l => l.id.includes('isochrone')),
],
}
}
return style
},
})
this.emitStyleLoad()
})
})
Expand Down

0 comments on commit c05a4ea

Please sign in to comment.