MapBox渐变折线轨迹-缩放地图时崩溃

问题描述

轨道的渐变折线可以正常显示,但是在缩放地图时会发生崩溃。 单色轨迹线正常工作。 可能是什么问题?

私人功能addpolyline(){

    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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...