【问题标题】:Need new method for linking to native mapping from mobile web app需要从移动 Web 应用程序链接到本机映射的新方法
【发布时间】:2012-09-20 03:34:41
【问题描述】:

我的移动网络应用程序使用地图链接,只需链接到“maps.google.com/maps?q=[something]”即可自动启动 Android 或 iPhone 的地图功能。 iOs 6 出来了,链接停止工作,因为 Apple 希望我们使用“maps.APPLE.com”。所以现在我必须专门检测 iOs 6 并换掉链接。

由于 iOs 6 削弱了它,有没有一种干净的方法可以从适用于 Android、iOs 6 和 iOs pre-6 的移动网络应用程序打开设备/本地地图应用程序? p>

原来您发送到“maps.apple.com”的任何内容都会转发到“maps.google.com”!

这两个链接都指向同一个地方

http://maps.google.com/maps?q=New+York

http://maps.apple.com/maps?q=New+York

Apple 开发网站上最近更新的文档... http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html#//apple_ref/doc/uid/TP40007894-SW1

【问题讨论】:

  • 在打开新的 Apple Maps 应用程序时,我没有使用缩放参数。文档表明支持 z 参数。无论我使用什么值,Apple Maps 应用程序中的缩放都不受影响。你有什么运气吗?

标签: android iphone mobile mobile-website ios6


【解决方案1】:

我在我的 iPhone 上试过这个,maps.apple.com 确实启动了新的 Apple Maps 应用程序(但我只在地址栏中输入了它)。当我在 iMac 上使用 Chrome 访问相同的链接时,我被重定向到 maps.google.com。我相信这是苹果故意的。如果您的目标是装有 iOS 6 的 iPhone,那么您需要从 google.com 切换到 apple.com。它应该是无缝的。

[确认 - 这适用于我的装有 iOS 6.0 的 iPhone - 我不再有 iOS 5.x 设备来确认这重定向到以前版本的 iOS。它确实在 Safari 中进行了重定向,但在 iPhone 模拟器中被破坏了]

// javascript snippet to detect ipad/iphone OS version - these are notoriously fragile, use at your own risk :)
function getOsVersion() {
var osVersion = window.navigator.userAgent.match(/(ipad|iphone);\s+cpu\s.*os\s+([_0-9]+)/i);
if (osVersion && osVersion.length === 3) {
    return Number(osVersion[2].replace('_', '.'));
}

return 0;

}

【讨论】:

    【解决方案2】:

    在 Android 中,您可以使用这些 Intent URI:

    geo:latitude,longitude
    geo:latitude,longitude?z=zoom
    geo:0,0?q=my+street+address
    geo:0,0?q=business+near+city
    

    例如:

    String uri = "geo:37.167629,-121.222478";
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri) );
    startActivity(intent);
    

    【讨论】:

      猜你喜欢
      • 2016-04-16
      • 2017-12-23
      • 1970-01-01
      • 2023-03-29
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 2015-02-26
      • 2014-05-22
      相关资源
      最近更新 更多