-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unable to filter a layer by whether a feature property is a substring of a literal string #9373
Comments
This looks like it can't really be solved fully: |
I suppose a style could use a string-in-string expression to test whether the current library supports #4113, but I agree it is quite an edge case. It might be worth documenting the |
We did something similar in https://github.com/mapbox/mapbox-gl-js-docs/pull/212 after getting several issues in which people supplied an array literal as the second argument to |
I've added a note to the docs regarding the workaround required for the very specific case which must be ambiguous for the sake of legacy compatibility. Since it's documented and since it's as it needs to be, I think there's not further action to be taken here. |
@rreusser @ryanhamley @kkaefer fyi... I was very confused by the explanatory comment in the docs (implemented in #10833) because it said "the second and third argument" rather than the "first and second argument". In order to understand which arguments this was referring to, I had to search for the relevant github issue. My understanding was that the |
Seconding here: the docs for this are unhelpful. Here's what would be useful:
In short, it's clear that something's deprecated, and something's new, but not clear what. |
An expression that tests whether some subexpression is a substring of another string gets interpreted as a legacy filter that is incapable of evaluating to
true
for any feature. To reproduce, load this style and observe that nothing is visible:colors.json
Expected results:
["in", ["get", "color"], "reddish"]
tests whether thecolor
property is a substring of “reddish”.Actual results:
["in", ["get", "color"], "reddish"]
is interpreted as a legacy filter, which expects the first parameter to be a property name, not a subexpression. The following error appears in the console:isExpressionFilter()
has logic specifically to avoid treating anin
expression as a filter as in mapbox/mapbox-gl-native#16262. However, it only considers whether the second parameter is an array (and thus an expression):mapbox-gl-js/src/style-spec/feature_filter/index.js
Lines 23 to 24 in 3f90780
/cc @mapbox/gl-js @zmiao @chloekraw
The text was updated successfully, but these errors were encountered: