如何使用 mapbox-ios 添加 "greater than sign" 线型(示例:>>>>)

How to add "greater than sign" line styles using mapbox-ios (example :>>>>)

我需要一条指向线来告诉别人一条线的顺序。

我使用 mapbox-ios 中的 MGLLineStyleLayer 添加了虚线样式(示例:- - - -) 但是我不知道它是否支持(>>>>)样式,或者箭头(--->---),请告诉我该怎么做。

您可以使用 MGLineStyleLayer.linePattern 属性 创建带箭头的线条。

首先,使用您要使用的模式创建一个 UIImage(在本例中,是一条带箭头的线)。然后使用 [MGLStyle setImage:forName] 将该图像添加到您的样式中。然后可以将该图像用于线条图案。

    func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
        if let image = UIImage(named: "arrow.png") {
            style.setImage(image, forName: "arrow")
            let source = MGLShapeSource(identifier: "polyline", shape: shapeFromGeoJSON, options: nil)
            style.addSource(source)

            let layer = MGLLineStyleLayer(identifier: "polyline", source: source)
            layer.linePattern = NSExpression(forConstantValue: "arrow")
            layer.lineWidth = NSExpression(forConstantValue: 10)
            style.addLayer(layer)
        }
    }