关于 mglfillerayer 和 MGLLineStyleLayer 的问题

Question about mglfillelayer and MGLLineStyleLayer

在mapbox_ios中: 1.关于MGLFillStyleLayer和MGLLineStyleLayer,如何为各个特征设置不同的样式(颜色,宽度,虚线)。

  1. 一个场景:如果是一个单独的多面体,不同地方的两个面之间没有连接,但它是一个特征,如果我想添加更多的多面体来修改图形(添加一个点并连接两个边),如何修改图形?

希望得到帮助,谢谢!

要回答您的第一个问题,您可以根据要素属性为样式图层中的各个要素设置样式。

adding the layers to your map. You could create your source, then style the layer's color based on the value in the feature attributes. Use the lineColor property for your MGLLineStyleLayer and fillColor 开始更改 MGLFillStyleLayer 的颜色。

例如:

        let layer = MGLLineStyleLayer(identifier: "layer", source: source)
        layer.lineColor = NSExpression(forKeyPath: "color")
        style.addLayer(layer)

您还可以创建一个字典,其中包含可能的属性值和您希望用作值的颜色。 This example 通过使用图标图像展示了该方法。