问题
I have to add polygon features in the 'MGLFillStyleLayer' with 'MGLPolygonFeature' but the problem is I can't change the outline width.
回答1:
The line width for a MGLFillStyleLayer currently cannot be changed. The suggested workaround is to use the same source to create a MGLLineStyleLayer, then insert the line layer above the fill layer.
I can add a line layer to this example with the following code:
let lineLayer = MGLLineStyleLayer(identifier: "line-layer", source: source)
lineLayer.lineWidth = MGLStyleValue(rawValue: 5)
lineLayer.sourceLayerIdentifier = "drone-restrictions-3f6lsg"
if let cityLabels = style.layer(withIdentifier: "place-city-sm") {
style.insertLayer(layer, below: cityLabels)
style.insertLayer(lineLayer, above: layer)
}
来源:https://stackoverflow.com/questions/48636433/how-to-add-linewidth-property-to-mglfillstylelayer-in-mapbox-ios-sdk