检查一个点是否落入地理围栏内?

时间:2011-12-23 19:06:49

标签: objective-c ios core-location geofencing

是否可以使用iOS 5 API检查给定的纬度和经度是否属于给定的GeoFence?怎么样?

1 个答案:

答案 0 :(得分:5)

简单的答案是肯定的:

CLRegion *region = your geofence;
CLLocationCoordinate2D myLocation = CLLocationCoordinate2DMake(38.9, -77.04);
if ([region containsCoordinate:myLocation]) {
   NSLog(@"You're soaking in it.");
}

请注意,目前仅支持圆形区域(“栅栏”)。请参阅Location Awareness Programming GuideCLRegion Class Reference