SymbolLayer iconImage not displaying when expression used
I'm trying to display an icon image depending on property value using "case" expression:
const iconStyles = {
stops: {
iconImage: stopIcon,
iconAllowOverlap: true,
iconSize: 0.1
},
vehicules: {
iconImage: [
'case',
['==', ['get', 'mode'], "Tram"],
tramIcon,
busIcon],
iconAllowOverlap: true
}
}
....
<MapboxGL.ShapeSource id="vehicules" shape={vehiculesGeoJson}>
<MapboxGL.SymbolLayer
id="myvehicules"
minZoomLevel={12}
style={iconStyles.vehicules}
/>
</MapboxGL.ShapeSource>
No icons are displayed.
I tried the same "case" approach for textFiled and works perfectly. Any ideas?
Thank you!
Are you even able to run this? Every time I do the same thing, my simulator crashes without trace.
@SethTyemill Yes I'm able to run it, but the symbols are not shown (the app it's not crashing). The only way I found to "solve" this was to create multiple ShapeSources....
@dalisalvador what is tramIcon and busIcon? With expressions we don't support react native images directly. Please use the Images component.
https://github.com/react-native-mapbox-gl/maps/blob/15cd5d36e917956ce541bbf0815580b90b5eda17/example/src/examples/ShapeSourceIcon.js#L78-L85