Ios 位置感知:接近坐标时发出通知
我有一个用于注释的多坐标数组。我正在尝试制作一个功能,以便当有人驾驶时,如果他们距离任何一个点都在1000米以内,手机上会弹出一个警报(如果应用程序在后台运行,则会弹出一个本地通知),上面会说:“你接近%@” 寻找最佳方法 提前感谢请参见《位置感知编程指南》中的Ios 位置感知:接近坐标时发出通知,ios,objective-c,maps,Ios,Objective C,Maps,我有一个用于注释的多坐标数组。我正在尝试制作一个功能,以便当有人驾驶时,如果他们距离任何一个点都在1000米以内,手机上会弹出一个警报(如果应用程序在后台运行,则会弹出一个本地通知),上面会说:“你接近%@” 寻找最佳方法 提前感谢请参见《位置感知编程指南》中的 您正在寻找的概念是地理围栏。如果你搜索这个关键词,你会发现很多教程和例子,说明如何使用CoreLocation实现这一点。嘿,Rob,我正在使用CoreLocation工作,我正在获取我的当前位置,我正在使用以下代码注册我的地区—(BO
您正在寻找的概念是地理围栏。如果你搜索这个关键词,你会发现很多教程和例子,说明如何使用CoreLocation实现这一点。嘿,Rob,我正在使用CoreLocation工作,我正在获取我的当前位置,我正在使用以下代码注册我的地区—(BOOL)RegisterRegionWithCircularRoverLay:(MKCircle*)overlay and identifier:(NSString*)identifier{},想知道这个方法什么时候被调用????
- (BOOL)registerRegionWithCircularOverlay:(MKCircle*)overlay andIdentifier:(NSString*)identifier
{
// Do not create regions if support is unavailable or disabled
if ( ![CLLocationManager regionMonitoringAvailable])
return NO;
// Check the authorization status
if (([CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorized) &&
([CLLocationManager authorizationStatus] != kCLAuthorizationStatusNotDetermined))
return NO;
// Clear out any old regions to prevent buildup.
if ([self.locManager.monitoredRegions count] > 0) {
for (id obj in self.locManager.monitoredRegions)
[self.locManager stopMonitoringForRegion:obj];
}
// If the overlay's radius is too large, registration fails automatically,
// so clamp the radius to the max value.
CLLocationDegrees radius = overlay.radius;
if (radius > self.locManager.maximumRegionMonitoringDistance) {
radius = self.locManager.maximumRegionMonitoringDistance;
}
// Create the region to be monitored.
CLRegion* region = [[CLRegion alloc] initCircularRegionWithCenter:overlay.coordinate
radius:radius identifier:identifier];
[self.locManager startMonitoringForRegion:region];
return YES;
}