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?
Asked
Active
Viewed 1,556 times
3
2 Answers
2
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.

Anup Cowkur
- 20,443
- 6
- 51
- 84
-
2but how can i use this for polygons? – Jithu P.S Jun 28 '13 at 06:31
-
Geofence API uses only circular regions for now. This might change later. If you want to use polygons, then you'll have to implement your own algorithms. This will be error prone and hard to do. I recommend using the circular geofences and the API unless you have a good reason not to do so. Here's a thread discussing geofencing using polygons : http://stackoverflow.com/q/924171/1369222 – Anup Cowkur Jun 28 '13 at 06:36
2
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)

Sam R.
- 16,027
- 12
- 69
- 122