只是为了让那些对解决方案有所了解的人,这是我编写的一个有用的 MKCircle 扩展,它检查一个点(在这种情况下是一个多边形点)是否在圆内。享受!
//MKCircle+PointInCircle.h
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface MKCircle (PointInCircle)
-(BOOL)coordInCircle:(CLLocationCoordinate2D)coord;
@end
//MKCircle+PointInCircle.m
#import "MKCircle+PointInCircle.h"
@implementation MKCircle (PointInCircle)
-(BOOL)coordInCircle:(CLLocationCoordinate2D)coord {
CLLocation *locFrom = [[CLLocation alloc] initWithLatitude:self.coordinate.latitude longitude:self.coordinate.longitude];
CLLocation *locTo = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];
double distance = [locFrom distanceFromLocation:locTo];
BOOL isInside = (distance <= self.radius);
return isInside;
}
@end