1
votes

I have a feature property that is an array of ids: feature.properties.ownerTypeIds: [1,2,3]

I have a form. In it it has a multi-select for Owner Types that produces an array: [1,2]

What is the mapbox gl latest version expression to compare a feature's array to an array of values? Match doesn't appear to support a feature property that is an array.

If ANY id in the feature's array is also in the selected choices array, I want it set to true. So that when it gets combined with many other filters inside an "all", it will work. The all works with many other filters, I just need help with the ownerTypeIds array scenario presented here.

Any value the user selects, is it inside the feature's ownerTypeIds array?

I'd appreciate any help. The mapbox expressions documentation doesn't appear to support feature properties that are an array. I hope I'm wrong in that assessment!

Appreciate you!

Thanks, Donnie

1

1 Answers

0
votes

From mapbox support ...

Hi Donnie,

Thanks for contacting Mapbox Support.

You are correct; only simple types are supported in Feature's properties. With that said, you cannot compare the two lists at runtime using the style spec. For your information, there is a publicly tracked issue here. https://github.com/mapbox/mapbox-gl-js/issues/2434

One workaround would be to create a new property that computes whether an element in one array also exists in another array and sets a true/false value. Then that boolean value can be used to compare in your filters.

Let me know if you still have any questions

Regards,