2

I'm working on an application based on Mapbox GL, I need to give to the user the opportunity to set the width and the color of the borders of polygons but I can't find the right GeoJSON proprieties to accomplish it. There's a way acting directly on polygon's GeoJSON or I need to create a whole new layer just to draw and customize the polygon's border?

0

3 Answers 3

5

For a layer of type: fill:

Border color could be set with the paint property fill-outline-color.

For the border width you'll need to use an additional layer, see: https://stackoverflow.com/questions/50351902/in-a-mapbox-gl-js-layer-of-type-fill-can-we-control-the-stroke-thickness/50372832#50372832

0
0

In the fill mode, you can't set the width. If you want to accomplish that, you will need to create a line mode layer after the fill mode layer with the same source. Example here:

https://docs.mapbox.com/mapbox-gl-js/example/geojson-polygon/

0

(2016) Border width is not possible because of WebGL technical limitations. Add another layer for the outline.

src: github

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.