Reputation: 1843
I am working with Geo-fencing in Android. I am able to draw a polygon on a map and get the latitude and longitude values of the vertices. My question is how can I determine when the user enters the polygon? Is there any way to determine whether the user is inside or outside the polygon?
Upvotes: 3
Views: 1576
Reputation: 16450
A bit late answer but you might use android-maps-utils which has a PolyUtil
class containing the following method:
// Computes whether the given point lies inside the specified polygon.
static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic)
Upvotes: 2
Reputation: 20563
You can use the Google Play Services Geofencing API launched in IO 2013 to do this quite easily.
Check out creating and monitoring geofences in the developer docs for a complete tutorial. Especially the handle geofence transitions section.
Upvotes: 2