maps icon indicating copy to clipboard operation
maps copied to clipboard

SymbolLayer iconImage not displaying when expression used

Open dalisalvador opened this issue 7 years ago • 3 comments

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!

dalisalvador avatar Sep 03 '19 07:09 dalisalvador

Are you even able to run this? Every time I do the same thing, my simulator crashes without trace.

SethTyemill avatar Sep 06 '19 19:09 SethTyemill

@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 avatar Sep 07 '19 07:09 dalisalvador

@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

mfazekas avatar Sep 07 '19 09:09 mfazekas