基础的调用定位的方法
-(void)viewDidLoad
{
//初始化BMKLocationService
_locService = [[BMKLocationService alloc]init];
_locService.delegate = self;
//启动LocationService
[_locService startUserLocationService];
}
//实现相关delegate 处理位置信息更新
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
//NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
}
1.如果使用了iOS模拟器,默认会定位到美国(可以在Xcode中更改)
一、选中模拟器:Debug - Location - Custom Location
20171108144855558.png
二、弹出的纬经度坐标、纬经度、纬经度坐标,默认显示的是苹果的官方坐标
20171108145613311.png
2.检查接收到的经纬度为字符串是否成功转化为正确的经纬度格式(Double类型)
3.检查经纬度是否传反了
4.检查经纬度是否为0
***234均有可能定位到大西洋,需要自己排除下
网友评论