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

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

问题描述

Apple开发者文档(链接是现在死了)解释说,如果你在网页上放置一个链接,然后在iPhone上使用Mobile Safari时点击它,那么随iPhone一起提供的标准的Google Maps应用程序将启动。

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及更低版本,请使用 openURL UIApplication 的方法。它将执行正常的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链接(并且它会提示输入位置信息,I相信)。

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天全站免登陆