Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
303 views
in Technique[技术] by (71.8m points)

Any possible way to start geofencing with Mapbox SDK for Android

I got severel points on my map and i would like to notify the user when he is within a 1km radius to a point. But i couldn't find a solution or example for this with the Mapbox SDK.

Is there another (easy) way to do this as a beginner?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

https://docs.mapbox.com/help/tutorials/android-location-listening/ shows how you can track a user's location with the Maps SDK for Android.

Every time you get a location update, you can run a calculation to determine whether the device's location is within 1km to the destination Point.

This calculation can be done many ways depending on whether the distance is straight line, how you want to visualize the distance, etc.

There's the within and distance expressions

https://docs.mapbox.com/android/java/examples/turf-circle-poi-within-filter/

https://docs.mapbox.com/android/java/examples/turf-physical-circle/

https://docs.mapbox.com/android/java/examples/turf-line-distance/

A simple Directions API call https://docs.mapbox.com/android/java/examples/show-directions-on-a-map


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...