通过传递纬度和经度打开Apple地图 [英] Open Apple Maps by passing latitude and longitude
问题描述
我尝试在用户点击链接时在PhoneGap应用中打开Apple地图。 Apple的文档中的URL方案类似于 http://maps.apple.com/maps?ll=51.83733,-8.3016
,它会打开Apple Maps(如果存在),否则重定向到Google地图。但是当我点击此链接时,它会打开Google Maps Web App,而无法返回应用程序。
I am trying to open Apple Maps in my PhoneGap app when a user clicks on a link. The URL scheme in Apple's documentation is like http://maps.apple.com/maps?ll=51.83733,-8.3016
, which opens Apple Maps if it is present, else redirects to Google Maps. But when I click on this link, it opens Google Maps Web App instead, and there is no way to go back to the app.
搜索解决方案此SO问题 - Phonegap - 在Apple Maps App中打开导航路线
建议使用 maps:
而不是 http://maps.apple.com/?q=somePlaceName
。这工作正常,并打开原生的苹果地图应用程序。但我想传递经度和纬度,而不是地名。
Searching for a solution, I found this SO question - Phonegap - Open Navigation Directions in Apple Maps App
It suggests using maps:
instead of http://maps.apple.com/?q=somePlaceName
. This works fine and opens the native Apple Maps app. But I want to pass latitude and longitude instead of a place name.
我尝试使用 maps?ll:51.84,-8.30
,但它不工作。
I tried with maps?ll:51.84,-8.30
, but it doesn't work.
推荐答案
您需要添加 InAppBrowser 插件到您的项目,并打开系统网络浏览器的链接,该链接将自动重定向到Apple地图:
You need to add the InAppBrowser plugin to your project and open the link with the system web browser, which will automatically redirect to Apple Maps:
var mapLocationUrl = 'maps.apple.com/?ll=51.84,-8.30';
var ref = window.open(encodeURI(mapLocationUrl), '_system', 'location=no');
检查官方 Apple URL方案参考以获取完整的参数列表。
Check the official Apple URL Scheme Reference for the complete list of parameters.
这篇关于通过传递纬度和经度打开Apple地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!