OGeek|极客世界-中国程序员成长平台

标题: ios - 在 iOS5 中打开原生 map 应用 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 16:21
标题: ios - 在 iOS5 中打开原生 map 应用

您好我最近不得不使用cordova打开设备上安装的 native map 。到目前为止,这是我所做的:

function getMapsUrl() {
   var isAndroid = navigator.userAgent.match(/Android/);
   var isIos = navigator.userAgent.match(/(iPhone|iPod|iPad)/);

   if (isAndroid) {
        return "geo:0,0?q=";
   }

   if (isIos) {
       return "maps:q=";
   }

   return "http://maps.google.com/maps?q=";
}

这个函数在应用程序第一次打开时被评估,一个带有字符串 get 的变量被整个应用程序全局使用来创建看起来像这样的链接,具体取决于设备:

 <a href="maps:q=Linie 27, 5405 AR UDEN, Nederland">iOS Version</a>
 <a href="geo:0,0?q=Linie 27, 5405 AR UDEN, Nederland">Android Version</a>

这适用于除 iOS5 以外的大多数设备。据我了解,这是因为苹果 map 是在 iOS6 中引入的,而 iOS5 仍然使用谷歌地图。

我已经尝试了所有这些以在 iOS5 上打开 native map 应用程序,但我没有运气:

  <a href="http://maps.google.com/maps?q=Linie 27, 5405 AR UDEN, Nederland">Android Version Q</a>
  br/>
  <a href="http://maps.apple.com/maps?q=Linie 27, 5405 AR UDEN, Nederland">iOS Version Q</a>               
  <br/>
  <a href="http://maps.google.com/maps?saddr=Linie 27, 5405 AR UDEN, Nederland">Android Version saddr</a>
  <br/>
  <a href="http://maps.apple.com/maps?saddr=Linie 27, 5405 AR UDEN, Nederland">iOS Version saddr</a>
  <br/>
   <a href="maps:q=Linie 27, 5405 AR UDEN, Nederland">iOS curent Version</a>
   <br/>
   <a href="maps://maps.apple.com/?q=Linie 27, 5405 AR UDEN, Nederland">IOS with google maps</a>
    <br/>
    <a href="maps:q=Linie 27, 5405 AR UDEN, Nederland">iOS curent Version</a>
    <br/>
    <a href="comgooglemaps://?q=Linie 27, 5405 AR UDEN, Nederland">From Google Docs for iOS app</a>
    <div data-bind="click: WindowOpenClick ">Window.Open</div>
    <div data-bind="click: WindowLocationClick">Window.location</div>
    <div data-bind="click: WindowOpenClickBlackPage">Window.Open Blank</div>

function WindowOpenClick() {
        var mapsUrl = "http://maps.google.com/maps?q=Linie 27, 5405 AR UDEN, Nederland";
        window.open(mapsUrl, '_system', 'location=yes');
    }

    function WindowOpenClickBlackPage() {
        var mapsUrl = "http://maps.google.com/maps?q=Linie 27, 5405 AR UDEN, Nederland";
        window.open(mapsUrl, '_blank', 'location=yes');
    }

    function WindowLocationClick() {
        var mapsUrl = "http://maps.google.com/maps?q=Linie 27, 5405 AR UDEN, Nederland";
        window.location.href = mapsUrl;
    }

我添加了上面的所有内容,但它们位于我的应用程序中的单独文件中。

有谁知道在 iOS5 中打开 map 应用的方法吗?



Best Answer-推荐答案


使用 Google Maps iOS 中提到的 URL 方案 comgooglemaps://?q=Linie 27, 5405 AR UDEN, Nederland。查看 link

关于ios - 在 iOS5 中打开原生 map 应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19905590/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4