是否可以使用MKMapView自己的位置管理器返回用户当前位置以传递到Web服务?
我有mapView.showsUserLocation=YES;,这确实在我的位置返回一个有效的蓝点,但在模拟器中,它的库比蒂诺 - 这很好,但当我看到
mapView.userLocation.coordinate.latitude,它等于180,而CLLocationManager返回正确的,37.3317.
我想避免为我的三个选项卡设置多个位置管理器,因此使用mapViews会有所帮助.
谢谢.
我的应用程序知道当前用户位置(CoreLocation.framework).一旦用户打开新的MapView,他的iPhone就会再次开始搜索当前位置.是否可以跳过它或更改mkMapView的第一个用户位置?
编辑:
是否可以覆盖MKMapView并使用其他LocationManager?
我试图使用CLLocationCoordinate2D获取用户的当前位置.我希望格式的值如
CLLocationCoordinate2D start = {-28.078694,153.382844};
所以我可以使用它们如下:
NSString *urlAddress = [NSString
stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f",
start.latitude, start.longitude,
destination.latitude, destination.longitude];
Run Code Online (Sandbox Code Playgroud)
我用了
CLLocation *location = [[CLLocation alloc]init ];
CLLocationDegrees currentLatitude = location.coordinate.latitude;
CLLocationDegrees currentLongitude = location.coordinate.longitude;
Run Code Online (Sandbox Code Playgroud)
获得当前的lat和long.
但是当我尝试测试时,我得到了0.000.我在iPhone 4s上测试.
如果有任何示例代码,那就太棒了.