首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >userLocation:纬度/经度返回零?

userLocation:纬度/经度返回零?
EN

Stack Overflow用户
提问于 2010-07-05 19:05:48
回答 1查看 1.1K关注 0票数 0

我只是在看mapKit,并决定制作一个快速按钮来显示我的当前位置,但是当我按下按钮时,我的纬度/经度始终显示为0.000000。

在我按下按钮之前,mapView已经加载,因为我可以在模拟器上看到地图。在此之前,我已经通过使用coreLocation.framework和CLLocationManager并以这种方式询问设备位置来完成此操作。我只是好奇为什么这种方式不能正常工作,我通过CLLocationManager来做会更好吗?

代码语言:javascript
复制
-(IBAction)findMePressed {
    MKUserLocation *myLocation = [myMapView userLocation];
    CLLocationCoordinate2D coord = [[myLocation location] coordinate];
    [myMapView setCenterCoordinate:coord animated:YES];
    NSLog(@"findMePressed ...[%f][%f]", coord.latitude, coord.longitude);
}

编辑:已添加...

代码语言:javascript
复制
-(IBAction)findMePressed {
     MKUserLocation *myLocation = [myMapView userLocation];
     CLLocationCoordinate2D coord = [[myLocation location] coordinate];
     MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 350, 350);
     [myMapView setRegion:region animated:YES];
}

-(void)viewDidLoad {
    [super viewDidLoad];
    [myMapView setShowsUserLocation:YES];
}

加里。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-07-05 20:37:41

userLocation在地图上不可见(请参阅userLocationVisible属性),或者在设置myMapView属性时出现问题,它为nil (即未在接口构建器中连接)

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

https://stackoverflow.com/questions/3178965

复制
相关文章

相似问题

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