Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
systemlevel opened this issue May 30, 2019 · 7 comments
Closed

Comments

@systemlevel
Copy link
Contributor

systemlevel commented May 30, 2019

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.

@mfazekas
Copy link
Contributor

@systemlevel seems to be an upstream mapbox-native-gl / ios issue. The expression is converted to NSPredicate then back to mapbox expression.

[
                'all',
                ['==', '$type', 'Point'],
                ['in', 'type', 'Blue Project', 'WFW Project']
            ]

Becomes NSPredicate predicateWithMGLJSONObject

"$type" == "Point" AND MGL_FUNCTION("in", "type", "Blue Project", "WFW Project") == 1

Which becomes predicate mgl_jsonExpressionObject

[
                'all',
                ['==', '$type', 'Point'],
                ['==', ['in', 'type', 'Blue Project', 'WFW Project'], 1],
            ]

And then it fails to parse this expression.

@mfazekas
Copy link
Contributor

Bug was reported to upstream repo: mapbox/mapbox-gl-native#14805

@systemlevel
Copy link
Contributor Author

@mfazekas thanks so much for reporting that upstream.

@lpfunding
Copy link

lpfunding commented Jun 3, 2019

Would this issue hinder the EarthQuakes.js example from working? I tried to build it in the exact same way, but the app crashes everytime I launch...

Any idea how long this bug will take to fix?

I believe this issue also exists in SymbolLayer!

@mfazekas
Copy link
Contributor

mfazekas commented 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']]}

@mfazekas
Copy link
Contributor

mfazekas commented Jun 6, 2019

The "!has" issue was reported to upstream: mapbox/mapbox-gl-native#14861

@mfazekas
Copy link
Contributor

mfazekas commented 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" ...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants