0

In mapbox_ios: 1. About MGLFillStyleLayer and MGLLineStyleLayer, how to set different styles (color, width, dotted line) for individual features.

  1. A scene: if it is a separate polyhedron with no connection between the two surfaces in different places, but it is a feature, if I want to add more polyhedron to modify the graph (add a point and connect the two sides), how to modify the graph?

Hope to get help, thank you!

Calm
  • 70
  • 8
  • Would you like to add a polyhedron to a map, or is that a separate question? – jmkiley Aug 07 '19 at 15:37
  • 1 and 2 are separate problems. In 2, I want to change the shape of a polyhedron by adding the form of a point, and I want these to be operated by the user, so I am not clear about how to associate the newly added coordinate point with polyhedron. – Calm Aug 08 '19 at 01:51
  • In geojson, each feature has a color attribute, and I want to directly color each feature through this attribute, but I haven't found a similar method in IOS. – Calm Aug 08 '19 at 09:58

1 Answers1

0

To answer your first question, you can style individual features within a style layer based on feature attributes.

Get started by 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 to change the color of your MGLFillStyleLayer.

For example:

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

You can also create a dictionary with possible attribute values and the color you would like to use as values. This example shows that approach by using icon images.

jmkiley
  • 976
  • 5
  • 8
  • Jmkiley, thank you for your method. The first problem should have been solved. Today I studied the second problem, which is too difficult – Calm Aug 09 '19 at 09:13