Ios 如何将区域的地理围栏添加到监测中。

Ios 如何将区域的地理围栏添加到监测中。,ios,objective-c,location,mapkit,geofencing,Ios,Objective C,Location,Mapkit,Geofencing,问题是,这里我提供了一个我正在检查的静态区域(中心) 但要求是,这一地区的车手数量会有所不同 我在字典数组中找到了所有的lat n long。首先,驾驶员将选择列表中的第一个车手,此时我需要车手1位置的区域。 我不知道如何才能做到这一点 如果我真的喜欢这个 - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { // If it's a re

问题是,这里我提供了一个我正在检查的静态区域(中心) 但要求是,这一地区的车手数量会有所不同

我在字典数组中找到了所有的lat n long。首先,驾驶员将选择列表中的第一个车手,此时我需要车手1位置的区域。 我不知道如何才能做到这一点

如果我真的喜欢这个

- (void)locationManager:(CLLocationManager *)manager

     didUpdateLocations:(NSArray *)locations {

    // If it's a relatively recent event, turn off updates to save power
    NSLog(@"%@ locations",locations);

    float Lat = _locationManager.location.coordinate.latitude;
    float Long = _locationManager.location.coordinate.longitude;

    NSLog(@"Lat : %f  Long : %f",Lat,Long);

    CLLocationCoordinate2D center = CLLocationCoordinate2DMake(28.52171,77.2015457);

    NSLog(@"center check %@",center);
    CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:center
                                                                 radius:500
                                                             identifier:@"new region"];
    BOOL doesItContainMyPoint = [region containsCoordinate:CLLocationCoordinate2DMake(Lat,Long)];

    NSLog(@"success %hhd", doesItContainMyPoint);

}

然后,它将如何知道第一个区域将被监视,并且在从该范围i hv存在后检查第二个位置

您可以动态创建区域并将其添加到监视中

for (NsMutableDictionary * dict in goersList)
    {
        rider_id=[dict valueForKey:@"trip_id"];
        lat=[dict valueForKey:@"origin_lat"];
        longi=[dict valueForKey:@"origin_long"];

}
这里有几个区域被添加到监控中。您可以一次添加一个。i、 e关于tableview的选择

并删除其他使用以下代码

for (NSDictionary *dict in [result valueForKey:@"Geofences"])
{
    NSLog(@"%@",dict);
    CLLocationCoordinate2D locationCoordinate=CLLocationCoordinate2DMake([[dict valueForKey:@"cLatitude"]doubleValue], [[dict valueForKey:@"cLongitude"]doubleValue]);

    CLCircularRegion *circularRegion=[[CLCircularRegion alloc]initWithCenter:locationCoordinate radius:[[dict valueForKey:@"Radius"]doubleValue] identifier:[dict valueForKey:@"Name"]];

    circularRegion.notifyOnEntry=YES;
    circularRegion.notifyOnExit=YES;
    [[AppDelegate sharedDelegate].locationManager startMonitoringForRegion:circularRegion];
    NSLog(@"%@",[[[AppDelegate sharedDelegate] locationManager].monitoredRegions description]);
}

您需要动态添加区域并监视这些区域,还需要在运行时删除这些区域。请在这里@Vatsal查看[result valueForKey:@“Geofences”]的内容K@pooja_1205它是包含所有地理围栏的阵列。我已经看到了上面提到的链接u,甚至我的要求几乎相同。所以我已经完成了这个task@pooja_1205谢谢祝你一切顺利:)我需要你的帮助@Vatsal K
for (CLRegion *monitored in [[AppDelegate sharedDelegate].locationManager monitoredRegions])
{
    [[AppDelegate sharedDelegate].locationManager stopMonitoringForRegion:monitored];
}