0

我有一组用于注释的多个坐标。我正在尝试制作一个功能,因此当有人开车并且他们在任何点的 1,000m 范围内时,手机上会弹出一个警报(如果应用程序在后台运行,则类似于本地通知)说,“你是靠近 %@”

寻找最好的方法,

提前致谢

4

1 回答 1

0

请参阅位置感知编程指南中的监控基于形状的区域。

- (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;
}
于 2013-06-12T02:51:00.073 回答