0

I'm adding a tile layer (Feature Collection?) from a Geoserver to a Mapbox GL JS map and all of the geometry appears to be coming across fine for me. What I can't for the life of me work out is how to ensure that default styling information also comes across from Geoserver into Mapbox. I have the styling setup using MBStyles as a simple red line color for now and it works in the (OpenLayers based?) preview but Mapbox stubbornly displays just black lines.

Every example I can find online people are hardcoding the style into their addLayer or addSource functions but this is not the right approach for me - I need to retrieve this from Geoserver. Or rather have it automatically be applied.

I have started to go down the route of changing permissions on the REST api access, trying to retrieve the MBStyle string that way etc but surely I am going about this the wrong way?

Anyone tried to do this?

Surely the point in using the MBStyle plugin is to have the style be applied automatically?

Examples / tutorials on this workflow seem to be pretty much non-existent.

1 Answer 1

3

The point of the MBStyle plugin is to allow GeoServer to render MapBox styles as a fallback, in case the client in question cannot, or is not willing to, use vector tiles, and would prefer using PNGs instead.

The OGC protocols have no way to advertise which style is meant to be applied on a given vector data source (be it vector tiles or WFS), and Leaflet is built to have the style loaded programmatically, not by protocol (the XYZ protocol only supports retrieving the vector tiles themselves).

The idea of opening parts of REST so that you can look up the layer, the associated style, and load it into the client, is a good one. But you'll have to program it yourself, it's just not going to happen automatically.

Another possibility, requiring some development, would be to extend the TileJSON document that the WMTS capabilities links to, for every layer, to include a style reference, in case the style happens to be MBStyle. To give you an idea of the surroundings:

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.