这是我创建地理围栏的代码:
Geofence *geofence = [[Geofence alloc] init];
[geofence setRadius:100.0];
[geofence setIdentifier: @"Fence1"];
[geofence setLocation:currentlocation];
CLRegion *region1 = [[CLCircularRegion alloc] initWithCenter:[geofence.location coordinate]
radius:geofence.radius
identifier:geofence.identifier];
region1.notifyOnEntry=YES;
region1.notifyOnExit=YES;
[self.locationManager startMonitoringForRegion:region1];
我可以说,上面的代码有效,这意味着地理围栏已经创建。但是我遇到了一个问题。
我有一个 .gpx 文件(我将在其中模拟我当前的位置),它们与区域/地理围栏中心的距离如下:55m、90m、150m、200m、300m、500m、1Km、5Km和 10 公里。
我的问题是,我的地理围栏半径似乎并不是真正的 100m,因为当我使用距地理围栏中心的距离为 55m、90m、150、200m、300m、500m、1km 的 gpx 文件进行模拟时。LocationManager -didEnterRegion
和的委托方法-didExitRegion
正在做出响应,即我在半径仅为“100m”的地理围栏内。
只有距离我的地理围栏中心 5 公里和 10 公里的 gpx 文件才响应我在地理围栏之外的上述委托方法。
你能帮我解决这个场景吗?