-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
diffStyleUpdates does not reload layers #146
Comments
I suspect that fixing #138 will make things work properly here. |
Great, thanks! A slightly modified version of the fix mentioned in that thread worked for me: $: map?.setStyle($isDarkTheme ? darkTheme : lightTheme, {
transformStyle: (previousStyle, nextStyle) => {
if (previousStyle) {
const customLayers = previousStyle.layers.filter(l =>
["line-", "fill-", "heatmap-"].some(prefix => l.id.startsWith(prefix))
)
const layers = nextStyle.layers.concat(customLayers)
const sources = nextStyle.sources
for (const [key, value] of Object.entries(previousStyle.sources || {})) {
if (key.startsWith("geojson-") || key.startsWith("heatmap")) {
sources[key] = value
}
}
return {
...nextStyle,
sources: sources,
layers: layers,
}
}
return nextStyle
},
}) Theme switching is now instant and works pretty well! Before that, without I also needed to set the |
That’s great! Thanks for sharing your solution :) |
Hi, thanks for the great library!
I noticed that when using
diffStyleUpdates
set totrue
and changing the style, it seems that nostyle.load
event is generated by maplibre, resulting in all the layers not being reloaded after getting nuked.The text was updated successfully, but these errors were encountered: