1
votes

How can I control the icon of each feature inside a SymbolLayer?

I saw this in the documentation but I dont know how to use it;

public static <T> PropertyValue<Function<T,String>> iconImage(Function<T,String> function)

Method documentation here said - name of image in sprite to use for drawing an image background. A string with {tokens} replaced, referencing the data property to pull from. ({token} replacement is only supported for literal iconImage(java.lang.String) values; not for property functions.)

Functions are used to change properties in relation to the state of the map. The value for any layout or paint property may be specified as a function. Functions allow you to make the appearance of a map feature change with the current zoom level and/or the feature's properties.

Functions.property() Source functions allow the appearance of a map feature to change with its properties. Source functions can be used to visually differentiate types of features within the same layer or create data visualizations. Each stop is an array with two elements, the first is a property input value and the second is a function output value. Note that support for property functions is not available across all properties and platforms at this time.

Any idea would be very helpful.

1
We recently created a blogpost covering this topic, you can find it at blog.mapbox.com/… - Tobrun
@Tobrun cool, thank you! - Hohenheim
Hi @Tobrun one quick question. What will happen if I add an image to the map with an existing key? And what will happen to the features if the image pointed by there key changed? or even gone? are they going to be updated as well? - Hohenheim

1 Answers

1
votes

They actually made a blogpost for this. Its found here written by Tobrun. Very cool. Without this I'd be making 1 layer per feature.