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

An expression to check if an array contains a string #6473

Closed
jc211 opened this issue Apr 7, 2018 · 6 comments
Closed

An expression to check if an array contains a string #6473

jc211 opened this issue Apr 7, 2018 · 6 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏

Comments

@jc211
Copy link

jc211 commented Apr 7, 2018

I have a geojson property which is an array. I would like to have an expression that checks if that array contains a certain string.
['has', 'mystring', ['get', 'myarray']]

Is this possible currently? If not, would it be possible to make the existing 'has' expression operate on arrays as well as objects?

@anandthakker anandthakker added feature 🍏 cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) labels Apr 9, 2018
@anandthakker
Copy link
Contributor

It's not possible currently, but I agree that it's something we should add.

@Macksen
Copy link

Macksen commented Apr 12, 2018

I recently discovered that I am in need of a similar expression, but that also takes an array input containing multiple strings and compares them to the values in the feature array property, is that possible to look at in the same issue?

@Twansparant
Copy link

That's too bad, is there a workaround?
What if I'm able to explode the array as a comma separated string or something?
Could I use an expression to search for the presence of the value as part of another string?
Thanks!

@anandthakker
Copy link
Contributor

@Twansparant that also doesn't yet exist, but is something we're planning to add. Most directly tracked at #6228

@Twansparant
Copy link

Thanks for your replies @anandthakker!

@jfirebaugh
Copy link
Contributor

Duplicate of #4698.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) feature 🍏
Projects
None yet
Development

No branches or pull requests

5 participants