• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 在 iOS5 中打开原生 map 应用

[复制链接]
菜鸟教程小白 发表于 2022-12-12 16:21:45 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

您好我最近不得不使用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/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap