定位

Xcode6高德地图定位注意事项

分类: iOS开发

再配置后工程后做如下几件事:

一、在plist中加两句(如图一):

NSLocationWhenInUseUsageDescription

NSLocationAlwaysUsageDescription

二、在UserLocationViewController中加三句(如图二):

    locationManager =[[CLLocationManager alloc] init];
    [locationManager requestAlwaysAuthorization];//用这个方法,plist中需要NSLocationAlwaysUsageDescription
    [locationManager requestWhenInUseAuthorization];//用这个方法,plist里要加字段NSLocationWhenInUseUsageDescription

 

#pragma mark getDistance
- (double)getDistanceWithLongitude:(float)longitude latitude:(float)latitude
{
    //    float dis;
    CLLocation *loca = [[CLLocation alloc]initWithLatitude:latitude longitude:longitude];
    // 计算距离
    CLLocationDistance meters=[_currentLoc distanceFromLocation:loca];
    return meters/1000;
}


图二:

三、获得经纬度:

posted @ 2015-01-11 21:56  曦阳  阅读(201)  评论(0编辑  收藏  举报