map-gl-utils
map-gl-utils copied to clipboard
Support changing style while keeping custom base layers
This might look like:
map.U.setStyle('mapbox://mapbox.blah', { discardRegex: 'mapbox://' })
Then:
- Fetch new style
- Find every source in current style whose URL doesn't match the discardRegex, add it to the new style
- Find every layer in current style belonging to a retained source, copy over`
Alternative:
map.U.checkpointStyle("beforeLoaded");
map.U.setStyle('mapbox://mapbox.blah', 'beforeLoaded`);
That is, define a name for this point in the style, and allow operations to diff between points.
Or something like this: https://github.com/mapbox/mapbox-gl-js/issues/2268#issuecomment-401979967
Just mulling over some more ideas here. A few possible design goals:
- more elegant way of loading a basemap and manipulating it, in one go. (ie, load style from server, but add additional layers, without having to wait for a map render between the two steps)
- make it easy to switch basemaps while retaining other layers
- make it easy to specify how custom layers sit within a basemap (eg, "below first symbol layer")