0

I am trying to do the following with react-native-mapbox-gl

<MapboxGL.SymbolLayer 
  id="controlPointIcon" 
  filter={['all', ['in', 'id', this.state.nextPossible], ['==', 'type', 'alt']]} 
  style={mapStyle.iconControlPoint} 
/>

The filter is supposed the match only if the given GeoJSON feature has its property id included in the array this.state.nextPossible and if the property type matches 'alt'.

I am clearly doing something wrong, the error I am getting says:

Invalide predicate: "id" ... NSInvalidArgumentException 
reason [__NSCFNumber isEqualTOString:]: unrecognized selector sent to instance ...

Any idea how to solve this with mapbox filter expressions?

mzu
  • 759
  • 8
  • 20
  • This might be related to this issue: https://github.com/react-native-mapbox-gl/maps/issues/70 – mzu Sep 20 '20 at 18:02

1 Answers1

2

See https://github.com/react-native-mapbox-gl/maps/issues/70#issuecomment-499775185 in is a legacy filter syntax and not supported. Please use match instead.

<MapboxGL.SymbolLayer 
  id="controlPointIcon" 
  filter={
      ['all', 
         ['match', 
            'id', this.state.nextPossible, true, 
            false
         ], 
         ['==', 'type', 'alt']
      ]} 
  style={mapStyle.iconControlPoint} 
/>
mfazekas
  • 5,589
  • 1
  • 34
  • 25