In my application I want to do geo-service. I have a list of locations for which I set geoprocessing regions. The entire location has a radius of 100 m . Below is the code for installing Region:
CLLocationCoordinate2D cord;
cord.latitude = [location.latitude doubleValue];
cord.longitude = [location.longtitude doubleValue];
CLLocationDistance regionRadius = location.radius;
CLRegion *region = [[CLRegion alloc] initCircularRegionWithCenter:cord radius:regionRadius identifier:[NSString stringWithFormat:@"%d",location.locId]];
[appDelegate.locationManager startMonitoringForRegion:region];
My problem is that it is not working properly. For debugging, the didEnterRegion delegate added a remote calculation between the current location and the location of the region several times, this distance is more than 1500 m .
Below is the code for calculating the distance between the current location and the location of the region:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
CLLocation *loc1 = locationManager.location;
CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:region.center.latitude longitude:region.center.longitude];
double dist = [loc1 distanceFromLocation:loc2];
}
Any idea why it is -locationManager:didEnterRegion:working so wrong?