Raju
Raju

Reputation: 250

Mapbox : How to change MGLFillStyleLayer "fill-outline-width"

Can I know is there any option to change the MGLFillStyleLayer "fill outline width” to custom width,

 let fillStyleLayer = MGLFillStyleLayer(identifier: identifier, source: source)

 fillStyleLayer.sourceLayerIdentifier = identifier

 fillStyleLayer.fillColor = MGLStyleConstantValue<UIColor>(rawValue: .red)
 fillStyleLayer.fillOpacity = MGLStyleConstantValue<NSNumber>(rawValue: 0.2)
 fillStyleLayer.fillOutlineColor = MGLStyleConstantValue<UIColor>(rawValue: .red)
 fillStyleLayer.predicate = predicate
 fillStyleLayer.isVisible = true
 self.mapView.style?.addLayer(fillStyleLayer)

Like this,

 fillStyleLayer.fillOutlineWidth = MGLStyleConstantValue<NSNumber>(rawValue: 5) 

Thanks.

Upvotes: 2

Views: 993

Answers (1)

jmkiley
jmkiley

Reputation: 976

It currently is not possible to adjust the outline/stroke width for a MGLFillStyleLayer. Relevant changes to the style spec are being discussed here: https://github.com/mapbox/mapbox-gl-js/issues/4087

Depending on your use case, one workaround is to create a MGLLineStyleLayer from the same source and style the lineWidth on that line. You can then add the line layer above the fill layer. This may not be ideal if you have multiple individual MGLFillStyleLayer objects, as this can impact performance.

let fillStyleLayer = MGLFillStyleLayer(identifier: identifier, source: 
...
self.mapView.style?.addLayer(fillStyleLayer)

let fillLineLayer = MGLLineStyleLayer(identifier: "line-layer", source: source)
fillLineLayer.lineWidth = MGLStyleConstantValue<NSNumber>(rawValue: 5)
mapView.style?.addLayer(fillLineLayer)

Upvotes: 2

Related Questions