Open Apple Maps by passing latitude and longitude

六月ゝ 毕业季﹏ 提交于 2019-12-08 08:50:59

问题


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.

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.

I tried with maps?ll:51.84,-8.30, but it doesn't work.


回答1:


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');

Check the official Apple URL Scheme Reference for the complete list of parameters.



来源:https://stackoverflow.com/questions/21447759/open-apple-maps-by-passing-latitude-and-longitude

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!