以编程方式在iOS 6中打开地图应用 [英] Programmatically open Maps app in iOS 6
问题描述
在iOS 6之前,打开这样的网址会打开(Google)地图应用:
Previous to iOS 6, opening a URL like this would open the (Google) Maps app:
NSURL *url = [NSURL URLWithString:@"http://maps.google.com/?q=New+York"];
[[UIApplication sharedApplication] openURL:url];
现在有了新的Apple Maps实现,这只会将Mobile Safari打开到Google Maps。如何在iOS 6中实现相同的行为?如何以编程方式打开地图应用并将其指向特定位置/地址/搜索/其他?
Now with the new Apple Maps implementation, this just opens Mobile Safari to Google Maps. How can I accomplish the same behavior with iOS 6? How do I programmatically open the Maps app and have it point to a specific location/address/search/whatever?
推荐答案
找到回答我自己的问题。 Apple记录其地图网址格式这里。看起来您基本上可以用 maps.apple.com
替换 maps.google.com
。
Found the answer to my own question. Apple documents its maps URL format here. It looks like you can essentially replace maps.google.com
with maps.apple.com
.
更新:事实证明,iOS 6上的MobileSafari也是如此;点击 http://maps.apple.com/?q = ...
的链接,以相同的方式打开地图应用 http://maps.google.com/?q = ...
在以前的版本中执行过。这有效,并记录在上面链接的页面中。
Update: It turns out that the same is true in MobileSafari on iOS 6; tapping a link to http://maps.apple.com/?q=...
opens the Maps app with that search, the same way http://maps.google.com/?q=...
did on previous versions. This works and is documented in the page linked above.
更新:这回答了我关于URL格式的问题。但是nevan king的回答这里(见下文)是对实际Maps API的一个很好的总结。
UPDATE: This answers my question relating to the URL format. But nevan king's answer here (see below) is an excellent summary of the actual Maps API.
这篇关于以编程方式在iOS 6中打开地图应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!