【问题标题】:Opening native maps app in iOS5在 iOS5 中打开原生地图应用程序
【发布时间】:2013-11-11 11:48:36
【问题描述】:

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

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 之外的大多数设备。据我了解,这是因为苹果地图是在 iOS6 中引入的,而 iOS5 仍然使用谷歌地图。

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

  <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 中打开地图应用的方法吗?

【问题讨论】:

    标签: ios ios5 cordova map


    【解决方案1】:

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

    【讨论】:

    • 如果你检查了我尝试过的最后一个链接但它不起作用,或者我需要先安装一些东西你有使用这个 sdk 的经验吗?
    • 你安装了谷歌地图吗?如果是,是安装的版本。
    • 我真的不知道如何检查,但它是iOS5默认自带的hte应用
    猜你喜欢
    • 2017-07-25
    • 2013-03-07
    • 1970-01-01
    • 2013-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-08-01
    • 2018-01-13
    • 1970-01-01
    相关资源
    最近更新 更多