Mapbox GL – Set Border Width and Color in Mapbox GL

geojsonjavascriptmapboxmapbox-glweb-mapping

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?

Best Answer

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