Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Added within expression filter example #1334

Merged
merged 1 commit into from
Apr 27, 2020

Conversation

langsmith
Copy link
Contributor

Resolves #1321 by adding an example of using a filter with the within expression, which allows developers to check whether or not a feature is in the bounds of a GeoJSON polygon. This enables styling point and line data differently if they’re fully within a polygon’s borders.

For now, this example is exactly the same as in the Maps SDK test app mapbox/mapbox-gl-native-android#288

Because we haven't ported Turf buffer (mapbox/mapbox-java#987), it's hard to make more responsive examples with within(). One example would be to draw a new directions route to the map click location, use buffer to calculate the new route's buffer area, and then the POIs would adjust accordingly.

ezgif com-resize

@langsmith langsmith merged commit 1f43cd3 into master Apr 27, 2020
@langsmith langsmith deleted the ls-adding-within-expression-filter-example branch April 27, 2020 14:43
@langsmith
Copy link
Contributor Author

Note to self/others. within() can be combined with a "circle". Not an actual CircleLayer, but a Polygon geometry with 360 steps: https://docs.mapbox.com/android/java/examples/turf-physical-circle. Would be good to make another example where a circle can be moved by clicking on the map and then new POIs are visible only within the circle.

Screen Shot 2020-04-27 at 9 03 00 AM

@mattRippin
Copy link

@langsmith Can this be used with VectorSource?

@langsmith
Copy link
Contributor Author

langsmith commented Oct 9, 2020

Yes it should work with a VectorSource @mattRippin

@mattRippin
Copy link

Yes it should work with a VectorSource @mattRippin

I logged an issue against it with some sample code and gave you a tag. I can't seem to identify what I'm missing.

Really appreciate the quick response from you btw.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example that shows within expression
3 participants