Igal Avraham
Igal Avraham

Reputation: 21

Mapbox on iOS - drawing icons dynamically according to attributes in source layer

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.

Upvotes: 2

Views: 194

Answers (1)

IvanovDeveloper
IvanovDeveloper

Reputation: 602

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")
...

Upvotes: 1

Related Questions