Question

I am using Geofencing. I want a method that checks whether or not a user is within certain boundaries.

I have the location as a CLLocationCoordinate2D which I've named location, and I have an array of 8 doubles, making up 4 coordinates (NW, NE, SW, SE). I can convert them to CLLocationCoordinate2D's. My question is, how can I check whether the location is within the boundaries? in iOS...

Was it helpful?

Solution

I don't think there's a built in method for this. You just check whether the location's latitude is less than the maximum boundary latitude and more than the minimum. Then the same with longitude.

If you convert them to MKMapPoint and MKMapRect, you can use MKMapRectContainsPoint() to check.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top