如何从我自己的本机应用程序中启动 Google Maps iPhone 应用程序? [英] How can I launch the Google Maps iPhone application from within my own native application?

查看:32
本文介绍了如何从我自己的本机应用程序中启动 Google Maps iPhone 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple 开发者文档(链接是死了)解释说,如果您在网页中放置一个链接,然后在 iPhone 上使用 Mobile Safari 时单击该链接,则作为 iPhone 标准提供的 Google 地图应用程序将启动.

The Apple Developer Documentation (link is dead now) explains that if you place a link in a web page and then click it whilst using Mobile Safari on the iPhone, the Google Maps application that is provided as standard with the iPhone will launch.

如何在我自己的本机 iPhone 应用程序(即不是通过 Mobile Safari 的网页)中以特定地址启动同一个 Google 地图应用程序,就像点击通讯录中的地址启动地图一样?

How can I launch the same Google Maps application with a specific address from within my own native iPhone application (i.e. not a web page through Mobile Safari) in the same way that tapping an address in Contacts launches the map?

注意:这仅适用于设备本身.不在模拟器中.

推荐答案

对于 iOS 5.1.1 及更低版本,使用 UIApplicationopenURL 方法.它将执行正常的 iPhone 神奇 URL 重新解释.所以

For iOS 5.1.1 and lower, use the openURL method of UIApplication. It will perform the normal iPhone magical URL reinterpretation. so

[someUIApplication openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=London"]]

应该调用 Google 地图应用.

should invoke the Google maps app.

从 iOS 6 开始,您将调用 Apple 自己的地图应用.为此,请使用要显示的位置配置 MKMapItem 对象,然后向其发送 openInMapsWithLaunchOptions 消息.要从当前位置开始,请尝试:

From iOS 6, you'll be invoking Apple's own Maps app. For this, configure an MKMapItem object with the location you want to display, and then send it the openInMapsWithLaunchOptions message. To start at the current location, try:

[[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil];

为此,您需要与 MapKit 建立链接(我相信它会提示进行位置访问).

You'll need to be linked against MapKit for this (and it will prompt for location access, I believe).

这篇关于如何从我自己的本机应用程序中启动 Google Maps iPhone 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆