joe*_*oec 27 iphone core-location mkmapview
是否可以使用MKMapView自己的位置管理器返回用户当前位置以传递到Web服务?
我有mapView.showsUserLocation=YES;,这确实在我的位置返回一个有效的蓝点,但在模拟器中,它的库比蒂诺 - 这很好,但当我看到
mapView.userLocation.coordinate.latitude,它等于180,而CLLocationManager返回正确的,37.3317.
我想避免为我的三个选项卡设置多个位置管理器,因此使用mapViews会有所帮助.
谢谢.
Dre*_*w C 44
您可以从MKMapView获取用户位置.您只是在检索它时遗漏了一个属性.它应该是:
mapView.userLocation.location.coordinate.latitude;
Run Code Online (Sandbox Code Playgroud)
userLocation仅存储CLLocation位置属性和BOOL更新属性.您必须转到location属性才能获取坐标.
-DREW
编辑:MKMapView的userLocation在地图加载完成之前不会更新,过早检查将返回零.为避免这种情况,我建议使用MKMapViewDelegate方法
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation.
| 归档时间: |
|
| 查看次数: |
29662 次 |
| 最近记录: |