question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SymbolLayer filter property data type error; unable to pass filter array

See original GitHub issue

Describe the bug SymbolLayer filter property docs specify passing a type array. When I pass an array to the filter property an exception is thrown saying “filter property must be a string”.

To Reproduce

       <Mapbox.ShapeSource>
          <Mapbox.SymbolLayer 
            id="guz" 
            style={{ visibility: "visible" }}
            filter={[
                'all',
                ['==', '$type', 'Point'],
                ['in', 'type', 'Blue Project', 'WFW Project']
            ]}
          />
        </Mapbox.ShapeSource>

Expected behavior The symbol layer should filter by the array passed into the SymbolLayer object.

Screenshots Screen Shot 2019-05-29 at 8 52 13 PM

Versions (please complete the following information):

  • Platfrom: iOS
  • Device: XR Simulator
  • React Native Version 0.59

Additional context Add any other context about the problem here.

In the project examples an array appears to be successfully used. For example, in the EarthQuakes.js example the CircleLayer appears to use an array filter:

            <MapboxGL.CircleLayer
              id="clusteredPoints"
              belowLayerID="pointCount"
              filter={['has', 'point_count']}
              style={layerStyles.clusteredPoints}
            />

Not sure why the SymbolLayer array I’m passing in is having the issue.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
mfazekascommented, Jun 7, 2019

It turns out in and '==',$type is legacy filter syntax, and it’s no longer supported. Use the new expression syntax to get it work:

["all",
    ["==",["geometry-type"], "Point"],
    ["match",
       ["get", "type"],
       ["Blue Project", "WFW Project"], true,
        false]
]

"!has" is legacy filter syntax too use ["!", ["has" ...]

1reaction
mfazekascommented, Jun 4, 2019

@lpfunding it seems that ios mapbox-gl-native have trouble with !has too - to be reported on upstream repo.

instead of

filter={['!has', 'point_count']}

you can try:

filter={['!', ['has', 'point_count']]}
Read more comments on GitHub >

github_iconTop Results From Across the Web

SymbolLayer filter property data type error; unable to pass ...
When I pass an array to the filter property an exception is thrown saying "filter property must be a string". ... The symbol...
Read more >
MapboxGL.SymbolLayer filter expression to check if id in array
state.nextPossible and if the property type matches 'alt'. I am clearly doing something wrong, the error I am getting says: Invalide predicate ......
Read more >
Expressions | Style Specification | Mapbox GL JS
Data expressions are allowed as the value of the filter property, ... If this check fails, it produces an error and causes the...
Read more >
How do I filter data in Flow? - Power Platform Community
Add a "Filter array" action, From set to output of "Get rows" action, within Condition box, click "Edit in advanced mode", type the...
Read more >
5. Filtering Data - ParaView Documentation
Similar to readers, the properties on the filter allow you to control the ... sphere, or a box) or using values of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found