首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何实现苹果地图ios 9的地理编码

如何实现苹果地图ios 9的地理编码
EN

Stack Overflow用户
提问于 2016-05-03 07:08:05
回答 1查看 152关注 0票数 0

我有两个位置,一个是司机,另一个是骑手,我有很长的时间可以使用这两个地方,我想当司机进入骑手位置的地理位置时,我想点击一个api。

我完成了QKGeofenceManager演示项目:使用它,我可以提供lat、n、long和半径来查找地理位置。

但问题是,每次在后台更新驱动程序位置以及应该应用什么条件,以便在驱动程序进入rider.If的地理区域时进行回调,ap处于后台,它将如何处理一切。我必须在appdelegate中做任何更改吗?

代码语言:javascript
复制
- (NSArray *)geofencesForGeofenceManager:(QKGeofenceManager *)geofenceManager
{
    NSArray *fetchedObjects = [self.fetchedResultsController fetchedObjects];
    NSMutableArray *geofences = [NSMutableArray arrayWithCapacity:[fetchedObjects count]];
    for (NSManagedObject *object in fetchedObjects) {
        NSString *identifier = [object valueForKey:@"identifier"];
        CLLocationDegrees lat = [[object valueForKey:@"lat"] doubleValue];
        CLLocationDegrees lon = [[object valueForKey:@"lon"] doubleValue];
        CLLocationDistance radius = [[object valueForKey:@"radius"] doubleValue];
        CLLocationCoordinate2D center = CLLocationCoordinate2DMake(lat, lon);
        CLCircularRegion *geofence = [[CLCircularRegion alloc] initWithCenter:center radius:radius identifier:identifier];
        [geofences addObject:geofence];
    }
    return geofences;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-05-09 11:46:19

我找到了一个替代方案来完成这项任务。由于没有调用我的Didenterlocation委托方法,所以我采用了另一种方法。

代码语言:javascript
复制
- (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.58171,77.2915457);

    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);

}

通过跟踪当前位置,每当当前位置坐标进入中心区域的坐标时,就可以发出用户已进入此特定区域的通知。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36997834

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档