Steps to reproduce
Currently, Mapbox seems to support only style layer properties determined by properties on the feature itself or, alternatively, from a computed variable such as $zoomLevel or $lineProgress. geojson-vt is responsible for varying $lineProgress along the path of the line feature. Beyond that one variable, there isn’t a general mechanism for integrating external data that varies along the path of the line.
Here's a simple use case.
- Create a MGLPolylineFeature layer
let polyline = MGLPolylineFeature(coordinates: &coordinates, count: UInt(coordinates.count))
self.polylineTrackSource = MGLShapeSource(identifier: "my-identifier", features: [polyline], options: [MGLShapeSourceOption.lineDistanceMetrics : true])
style.addSource(self.polylineTrackSource)
- Create a MGLFeature with attributes for above layer
let feature = MGLPointFeature()
feature.coordinate = location.coordinate
feature.attributes["elevation"] = location.altitude
- Style MGLLineStyleLayer.linegradient
layer.lineGradient = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:(elevation, 'linear', nil, %@)", [0: UIColor.blue, 10000: UIColor.red])
Expected behavior
Styling of MGLLineStyleLayer.linegradient based on feature attributes is supported.
The MGLLineStyleLayer.linegradient property does support applying interpolation or step functions to feature attributes.
Actual behavior
Styling of MGLLineStyleLayer.linegradient based on feature attributes (e.g. elevation) is not supported.
The MGLLineStyleLayer.linegradient property does not support applying interpolation or step functions to feature attributes.
Configuration
Mapbox SDK versions:
v4.6.0
iOS/macOS versions:
v12.x
Device/simulator models:
iPhone 7++
Xcode version:
V10, Swift 4