Pergunta

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...

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top