I have the swift code below that draws a polygon and drops an annotation on MKMapView. I am trying to figure out how i could identify if the annotation\'s coordinate is with
You can create a polygon renderer object and check if it's path contains the point based on the location in the map:
func checkIf(_ location: CLLocationCoordinate2D, areInside polygon: MKPolygon) -> Bool {
let polygonRenderer = MKPolygonRenderer(polygon: polygon)
let mapPoint = MKMapPointForCoordinate(location)
let polygonPoint = polygonRenderer.point(for: mapPoint)
return polygonRenderer.path.contains(polygonPoint)
}