[英]How will get current location in iphone
I am making google map integration in iphone.我正在 iphone 中集成谷歌 map。 I have to show current location showing in map.我必须在 map 中显示当前位置。 How will i get current location?我将如何获得当前位置?
Thanks谢谢
CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);
Search for Accessing the Device's Current Location
in following article:在以下文章中搜索Accessing the Device's Current Location
:
MKMapView Class Reference MKMapView Class 参考
MapView.showsUserLocation = YES;
)显示用户位置 ( MapView.showsUserLocation MapView.showsUserLocation = YES;
)Related SO posts:相关的SO帖子:
I think the question has been answered -我想问题已经回答了——
CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);
place this in the viewdidappear:animated
把它放在viewdidappear:animated
then you should find that you have the right location.那么你应该发现你有正确的位置。 Doing it any sooner and the location won't be set yet and you'll probably end up in the ocean:)尽快这样做,位置还没有确定,你可能最终会在海里:)
The short answer is to write code like mapview.showsUserLocation = YES;
简短的回答是编写类似mapview.showsUserLocation = YES;
的代码。 , where mapview is your UIMapView class object. ,其中 mapview 是您的 UIMapView class object。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.