问题描述
轨道的渐变折线可以正常显示,但是在缩放地图时会发生崩溃。 单色轨迹线正常工作。 可能是什么问题?
if (mapView?.style?.source(withIdentifier: "polyline") as? MGLShapeSource) == nil {
guard let style = mapView?.style else {return}
//let source = MGLShapeSource(identifier: "polyline",shape: nil,options: nil)
let source = MGLShapeSource(identifier: "polyline",options: [.linedistanceMetrics: true])
style.addSource(source)
polylinesource = source
// Add a layer to style our polyline.
let layer = MGLLinestyleLayer(identifier: "polyline",source: source)
layer.lineJoin = NSExpression(forConstantValue: "round")
layer.lineCap = NSExpression(forConstantValue: "round")
layer.lineColor = NSExpression(forConstantValue: UIColor.init(cgColor: #colorLiteral(red: 0.9372549057,green: 0.3490196168,blue: 0.1921568662,alpha: 1)))
let stops = [0: UIColor.red,0.1: UIColor.yellow,0.3: UIColor.green,0.5: UIColor.cyan,0.7: UIColor.systemBlue,1: UIColor.blue]
//FIXME: - CRACH when adding this line when zooming !!!!!!!!!!!!!
layer.lineGradient = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($lineProgress,'linear',nil,%@)",stops)
// The line width should gradually increase based on the zoom level.
layer.linewidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel,[13: 2,18: 5])
style.addLayer(layer)
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)