I was following the blog post from https://blog.mapbox.com/a-guide-to-the-android-symbollayer-api-5daac7b66f2c to add different symbols to a map.
Having different icons based on the feature value is already working, but changing the icon size, based on the "selected" property proves not as easy.
As it seems they changed/removed some methods/classes with the newer SDK i am not able to set the icon size based on a property value of the feature.
mapboxMap.addLayer(myLayer)
.withProperties(
PropertyFactory.iconSize(
Function.property(
"selected",
Stops.categorical(
Stop.stop(true, PropertyFactory.iconSize(1.5f)),
Stop.stop(false, PropertyFactory.iconSize(1.0f))
)
)
)
)
);
Thats how they did it in the example, but Stops.categorical()
does not exist anymore.
Im using com.mapbox.mapboxsdk:mapbox-android-sdk:7.3.0
For anybody else looking for an answer thats how i did solve it
iconSize(
match(get("selected"), // property selected is a number
literal(1), // default value
stop(0, 0.75), // if not selected set icon size to 0.75 of original value
stop(1, 1) // if selected set it to original size
)
)