-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Change theme after map init #176
Comments
I tried some thing like this ( layer.options.theme = style;
layer.clearLayout();
layer.rerenderTiles(); But this doesn't work |
My current workaround is following: ( import { leafletLayer } from "../../../node_modules/protomaps-leaflet/src/frontends/leaflet";
import { paintRules, labelRules } from "./node_modules/protomaps-leaflet/src/default_style/style";
import { themes } from ./node_modules/protomaps-leaflet/src/default_style/themes";
function setLayerStyle(layer, style) {
const theme = themes[style];
if (!theme) {
return;
}
layer.options.theme = style;
layer.paintRules = paintRules(theme);
layer.labelRules = labelRules(theme);
layer.backgroundColor = theme.background;
layer.clearLayout();
layer.rerenderTiles();
} |
I think that is a good workaround for now. We should provide a convenience method later for setting a style from a custom object or one of the preset theme names. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've build a map where the theme changes based on the interface settings (dark and light mode). Before, I had the function
setDefaultStyle
. But after v1 the function was removed. I've found nothing in the change log on how to achieve this functionality, on how to update the layer options afterwards. How can I do this?The text was updated successfully, but these errors were encountered: