I'm using a MGLSymbolStyleLayer
to render icons on a way on my mapbox instance on iOS.
My problem right now is the frequency that icon is drawn: I tried all the values of MGLSymbolPlacement as value for styleLayer.symbolPlacement
but none of them seems to satisfy my needs.
As you can see in the two attached images sometimes the red X are placed once along the way, sometimes more than once.
Using MGLSymbolPlacement.Point I achieved to have a single X on a way, but it would only be at its beginning.
My goal is to have a single X on each Way and placed at its middle point, half way between start and end. Is it achievable in any way?
Thanks
let styleLayer = MGLSymbolStyleLayer(identifier: identifier, source: source)
styleLayer.sourceLayerIdentifier = sourceLayerIdentifier
styleLayer.symbolPlacement = NSExpression(forConstantValue: MGLSymbolPlacement.line.rawValue)
styleLayer.iconImageName = NSExpression(forConstantValue: imageName)
styleLayer.iconScale =
NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)",
[13: 0.0, 15: 0.45])
styleLayer.iconRotationAlignment = NSExpression(forConstantValue: MGLIconRotationAlignment.viewport.rawValue)
styleLayer.iconAllowsOverlap = NSExpression(forConstantValue: true)
styleLayer.keepsIconUpright = NSExpression(forConstantValue: true)
styleLayer.iconOpacity =
NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)",
[13: 0, 14: 1])