Add iOS example data from API with dynamic styling (#2535)
This commit is contained in:
@@ -71,8 +71,7 @@ class LineStyleLayerExampleUIKit: UIViewController, MLNMapViewDelegate {
|
||||
layer.lineColor = NSExpression(forConstantValue: UIColor(red: 59 / 255, green: 178 / 255, blue: 208 / 255, alpha: 1))
|
||||
|
||||
// Use `NSExpression` to smoothly adjust the line width from 2pt to 20pt between zoom levels 14 and 18. The `interpolationBase` parameter allows the values to interpolate along an exponential curve.
|
||||
layer.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)",
|
||||
[14: 2, 18: 20])
|
||||
layer.lineWidth = NSExpression(forMLNInterpolating: NSExpression.zoomLevelVariable, curveType: MLNExpressionInterpolationMode.linear, parameters: nil, stops: NSExpression(forConstantValue: [14: 2, 18: 20]))
|
||||
|
||||
// We can also add a second layer that will draw a stroke around the original line.
|
||||
let casingLayer = MLNLineStyleLayer(identifier: "polyline-case", source: source)
|
||||
@@ -84,7 +83,7 @@ class LineStyleLayerExampleUIKit: UIViewController, MLNMapViewDelegate {
|
||||
// Stroke color slightly darker than the line color.
|
||||
casingLayer.lineColor = NSExpression(forConstantValue: UIColor(red: 41 / 255, green: 145 / 255, blue: 171 / 255, alpha: 1))
|
||||
// Use `NSExpression` to gradually increase the stroke width between zoom levels 14 and 18.
|
||||
casingLayer.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", [14: 1, 18: 4])
|
||||
casingLayer.lineWidth = NSExpression(forMLNInterpolating: NSExpression.zoomLevelVariable, curveType: MLNExpressionInterpolationMode.linear, parameters: nil, stops: NSExpression(forConstantValue: [14: 1, 18: 4]))
|
||||
|
||||
// Just for fun, let’s add another copy of the line with a dash pattern.
|
||||
let dashedLayer = MLNLineStyleLayer(identifier: "polyline-dash", source: source)
|
||||
|
||||
Reference in New Issue
Block a user