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

Multiple filters and to-number fails #757

Open
chau-intl opened this issue Nov 9, 2021 · 1 comment
Open

Multiple filters and to-number fails #757

chau-intl opened this issue Nov 9, 2021 · 1 comment

Comments

@chau-intl
Copy link

I am trying to create a filter which consists of an equal and a larger-than part:

A = 'my-value' AND number(B)> 2

This I write as:

 "filter": [
    "all",
    ["==", "A", "my-value"],
    [">", ["to-number", ["get", "B"]],2]
  ]

but it doesn't work giving me the error message: string expected, array found on the line with the to-number.

If I remove the equal filter, the greater-than filter works just fine:

 "filter": [
    "all",
    [">", ["to-number", ["get", "B"]],2]
  ]

What am I doing wrong?

I am using Maputnik 1.7.0.

@chau-intl
Copy link
Author

I have discovered, that if I change rewrite my original filter from:

 "filter": [
    "all",
    ["==", "A", "my-value"],
    [">", ["to-number", ["get", "B"]], 2]
  ]

to:

 "filter": [
    "all",
    ["==", ["to-string", ["get", "A"]], "my-value"],
    ["<", ["to-number", ["get", "B"]], 2]
  ]

it seems to work, though the UI isn't very helpful using these types of filters.

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

1 participant