Created
August 4, 2014 18:10
-
-
Save StuartFarmer/d398d66ebe64968e767e to your computer and use it in GitHub Desktop.
The following converts the coordinate to a CGPoint in the polygon view and uses CGPathContainsPoint to test if that point is in the path (which may be non-rectangular)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLLocationCoordinate2D mapCoordinate = ...; //user location or annot coord | |
MKMapPoint mapPoint = MKMapPointForCoordinate(mapCoordinate); | |
MKPolygonView *polygonView = | |
(MKPolygonView *)[mapView viewForOverlay:polygonOverlay]; | |
CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint]; | |
BOOL mapCoordinateIsInPolygon = | |
CGPathContainsPoint(polygonView.path, NULL, polygonViewPoint, NO); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment