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

Filter expression using 'all' with ['zoom'] and property doesn't work as expected #5651

Closed
jlocus opened this issue Nov 10, 2017 · 1 comment

Comments

@jlocus
Copy link

jlocus commented Nov 10, 2017

mapbox-gl-js version: 0.41.0

Steps to Trigger Behavior

  1. Start from the "Final Product" example here: https://www.mapbox.com/help/mapbox-gl-js-expressions/

  2. Modify the code to add a 'Filter' clause using both the 'Constructi' property and ['zoom']:

    'filter': ['all', ['>=', 'Constructi', 1930], ['>=', ['zoom'], 10]]

Example at: https://jsbin.com/losiwikipa/edit?html,output

Expected Behavior

Red circles should appear for items constructed after 1930 when the zoom level is >= 10

Actual Behavior

No red circles appear under any circumstances

These "all" clauses both work as expected:'

'filter': ['all', ['>=', 'Constructi', 1930], ['>=', 'Constructi', 1930]]
'filter': ['all', ['>=', ['zoom'], 10], ['>=', ['zoom'], 10]]
@jfirebaugh
Copy link
Contributor

Hi @jlocus, thanks for the report! There is indeed an issue here: the filter ['all', ['>=', 'Constructi', 1930], ['>=', ['zoom'], 10]] is invalid, and should have produced a validation error. I believe what you wanted was ['all', ['>=', ['number', ['get', 'Constructi']], 1930], ['>=', ['zoom'], 10]] -- note the use of number and get expressions as shown in the help guide. I've opened a PR that tightens up the validation to catch issues like this in the future.

(Also note that you can't mix the old filter syntax and new expression syntax in the same filter -- if the filter uses any new expression syntax, then the whole thing must be a valid expression.)

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

2 participants