ol-mapbox-style
ol-mapbox-style copied to clipboard
Rendering raster styles when using OpenLayers MapboxVector layer
I am attempting to create a MapboxVector layer, as one of many other layers in a larger application. The problem is raster style layers are ignored, as that is beyond the scope of applyStyle. Using olms is not feasible, given the management of the layers by the application. Is there a means to apply (or limit) olms to an layer group that was defined by the application?
~Looking how map is used within apply, I wonder if it would be the wiser if a layer group was sent to it instead of a map...~ Looks like apply needs the map view.
Currently there is no way to achieve what you want directly. But it should not be too hard to make applyStyle work with Tile layers, in addition to Vector and VectorTile layers.
Would that mean making the Tile layer url parameter optional in exchange for providing a style url parameter that the Tile layer can pull the tile url from, or would you expect that to be done up-front, and simply invoke the applyStyle if an additional style url parameter is passed?
Currently, when you call applyStyle() with a VectorLayer or VectorTile layer instance, ol-mapbox-style knows what to do with it. The same can be implemented for TileLayer. If the TileLayer has a source already, applyStyle will override its url or url loading function, same as for a VectorTile source. If it has no source yet, applyStyle() will create one.
Thanks...reviewed a lot of the code today, but missed that part. I'll look it over again.
@scadergit Thanks for digging into this. Let me know if I can help anywhere.
In that approach, the application would need to know up-front if a style definition included raster and/or vector layers, create separate layers for each, and call applyStyle() on each?
Correct. But I see your point now. It looks like what you are looking for are layers and sources options for apply(). Adding those would also be an acceptable solution. Those could be an array of layer or source ids, or a function that receives a Mapbox layer or source as argument and returns a boolean to indicate whether to include or not.
What if apply() was updated (or create applyGroup()?) to apply the new layers of the style definition to an OL group argument, and ignore any map/view style definition configuration?
It should be possible to extend the API so apply() also accepts a layer group in as first argument. In that case, mapbox-style property would be set on the layer group, and the background would be set on the first layer instead of the map.
I have a wip to review, can I get push permissions?
Just create a pull request.
Apparently my brain checked out early for the weekend...pull request created
Resolved in #648
Thanks, @ahocevar for your help on this effort.