如何获取 iPhone 中的当前位置

发布于 2024-11-14 22:40:06 字数 63 浏览 0 评论 0原文

我正在 iPhone 中集成谷歌地图。我必须显示地图中显示的当前位置。我如何获得当前位置?

谢谢

I am making google map integration in iphone. I have to show current location showing in map. How will i get current location ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苍景流年 2024-11-21 22:40:06
CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];  
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);
CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];  
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);
最单纯的乌龟 2024-11-21 22:40:06

我认为问题已经得到解答 -

CLLocationCoordinate2D location = [[[mapview userLocation] location] coordinate];  
NSLog(@"Location found from Map: %f %f",location.latitude,location.longitude);

将其放在 viewdidappear:animated

,然后您应该发现您拥有正确的位置。早点做的话,位置还没有确定,你可能最终会进入海洋:)

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

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 :)

心碎无痕… 2024-11-21 22:40:06

简短的答案是编写类似 mapview.showsUserLocation = YES; 的代码,其中 mapview 是您的 UIMapView 类对象。

The short answer is to write code like mapview.showsUserLocation = YES;, where mapview is your UIMapView class object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文