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

"in" expression not working in combination with other "in" expressions #9503

Closed
jliebrand opened this issue Apr 7, 2020 · 3 comments
Closed

Comments

@jliebrand
Copy link

I'm still trying to put this in a jsbin, but thought I'd get this down here first.

If I use the in expression to find a substring from a string, things work fine:

        [ "in", "needle", ["get", "$haystack"] ]

And if I use the in expression in the older(?) syntax, that works fine also:

        [ "in", "$type", "LineString", "Polygon" ],

But combining the two causes an error:

      "filter": [
        "all",
        [ "in", "$type", "LineString", "Polygon" ],
        [ "in", "needle", ["get", "$haystack"] ]
      ],

Error: layers[51].filter[2][2]: string, number, or boolean expected, array found
at Object.bn [as emitValidationErrors]

Am I doing something wrong, or is it not happy about the two formats of "in" ?

@ryanhamley
Copy link
Contributor

Based on that error message, the filter doesn't recognize that ['get', '$haystack'] is a sub-expression and is interpreting it as an array. If ['in', 'needle', ['get', '$haystack']] works fine on its own then I assume the error might be due to combining the two syntax types. If you can update the ticket with an example, that will help figure out the issue. For what it's worth though, the older syntax is considered deprecated and we'd recommend using only the expression syntax if possible.

@ryanhamley
Copy link
Contributor

@jliebrand Actually, our docs warn that you cannot combine the old and new syntax in a single filter statement. See https://docs.mapbox.com/mapbox-gl-js/style-spec/other/#other-filter. I'm going to close this in light of that. If you feel that something else is going on, let us know and provide a minimal example. Thanks!

@1ec5
Copy link
Contributor

1ec5 commented Apr 8, 2020

Related: #9373

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