Comments (11)
You could do something like
// clear everything from previous style
map.setLayerGroup(new ol.layer.Group());
// apply new style
olms.apply(map, satJson);
from ol-mapbox-style.
Thanks - Sadly this will remove all other layers like markers etc..
I've got a solution at the moment where i loop through the layers of the map and then remove the layer which is the tiles of the map. Its not pretty.
I'll look into the groups to see if i can use this.
I can have lots of markers displayed on a map and it would be nice if the style added through apply() could be stored in its own object... Is that possible?
Thanks
from ol-mapbox-style.
We're currently working on a solution where only changes from a previous apply()
or applyStyle()
call will be applied to the map. This will result in what you're looking for.
In the meantime, you can loop through the existing layers and only remove those that have a mapbox-layers
property.
from ol-mapbox-style.
Thats sounds great - is there an approx timescale for that?
thanks
from ol-mapbox-style.
Should be done in a few weeks.
from ol-mapbox-style.
also trying to get the mapbox-layers property.
If i'm looping through all the layers - I've looked at each object and cannot see a property matching the above.
_map_layers = map.getLayers().getArray()
_map_layers.forEach(function (_l) {
console.log(_l)
})
from ol-mapbox-style.
Try this:
const layers = map.getLayers().getArray();
for (let i = layers.length - 1; i >= 0; --i) {
const layer = layers[i];
if (layer.get('mapbox-layers')) {
map.removeLayer(layer);
}
}
from ol-mapbox-style.
Thanks - that's great..
Look forward to the new release as well
thanks for the quick replies.
from ol-mapbox-style.
Hello @ahocevar just checking in on this toggle issue to see if the solution you mention here has been implemented. I am also trying to toggle between a 'streets' and 'imagery' layer (from map tiler) and can't seem to work out the pattern. Is your solution above still the correct approach or is there a new\better way. Thank you for your work and input.
from ol-mapbox-style.
Unfortunately this has not been implemented yet, but I may be able to get this feature funded and implemented before the end of the year.
The snipped I posted in #77 (comment) should still work. Just call it before applying the new style to the existing map.
from ol-mapbox-style.
That's exactly what I did and it works great. thx
from ol-mapbox-style.
Related Issues (20)
- Requests to third-party server for fonts HOT 8
- issue with standalone example using recent versions of olms (METERS_PER_UNIT error) HOT 1
- applyBackground issue HOT 3
- line-pattern webgl HOT 3
- Provide a default URL template for fonts when 'ol:webfonts' not available HOT 1
- Issue rendering fill layers above symbol layers HOT 2
- 加载mapboxgl的样式时文本标签显示错乱 HOT 1
- Maybe a bug in stylefunction HOT 2
- Vector tile layer with MVT format clip circle style HOT 6
- color2 is null loading outdoor-v2 HOT 1
- Example of using a styled Esri vector tiles basemap (but not as the whole map) HOT 1
- Text-Allow-Overlap and Declutter issues. HOT 6
- Incorrect Tiles being requested for projections other than Web Mercator (EPSG:3857) HOT 2
- render vector tiles offline, or render vector tiles to raster for later offline use? HOT 3
- Applying style to VectorTile layer HOT 2
- Displaying symbols from sprites HOT 6
- fill-pattern position bug HOT 2
- Security: Remove Links to Polyfill.io HOT 1
- missing icon-text-fit property HOT 2
- Declutter of labels in vector tiles HOT 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ol-mapbox-style.