1
votes

Does anyone has a sample of implementation of dynamically drawing icons according to location and feature attributes in the source?

I can not make it work.

NSExpression is not giving the correct values, it looks like it is not reading the attributes values.

1

1 Answers

0
votes

You can use this Mapbox article to understand how you can change markers regarding zoom level.

If you will provide description how exactly do you want dynamically change icon we can find the solution for you.

For example in my apps I need to display different icon regarding attribute value for the feature

...
feature.attributes = [
   "pin_icon": pinType.selectedPinType.rawValue //icon_key_name
]
...
...
let layer = MGLSymbolStyleLayer(identifier: "markers", source: source)

layer.iconImageName = NSExpression(forKeyPath: "pin_icon")
...