【问题标题】:Google Maps link for iOSiOS 版 Google 地图链接
【发布时间】:2013-02-05 19:27:20
【问题描述】:

我想在我们公司的移动网站上有一个指向 Google 地图的链接。问题是,如果我做一个链接,它会把你带到谷歌地图网站。它需要打开应用程序。

我发现如果您以“comgooglemaps://”开头的网址,它将打开谷歌地图。但是,这会带来一个问题,即如果 iOS 用户没有安装 Google 地图,则该链接将无法使用。

如果安装了谷歌地图,有没有办法打开它,如果没有打开浏览器(我不相信你可以从网站打开苹果地图,因为它们的 API 的性质)

谢谢

编辑:请注意,这是在网站上完成的,而不是在应用程序上。所以它需要通过 HTML、Javascript、PHP 等来完成,而不是编程语言。

【问题讨论】:

  • Javascript 和 PHP 是编程语言。
  • 你有没有解决过这个问题。我有同样的要求吗?
  • 自 2018 年起,您可以使用 Google 地图网址:stackoverflow.com/a/50413036/5140781

标签: iphone ios google-maps maps apple-maps


【解决方案1】:

看看Apple Maps Links page

基本上你链接到 maps.apple.com 并在需要时重定向到谷歌地图。这是页面中的一个示例:

http://maps.apple.com/?daddr=San+Francisco,+CA&saddr=cupertino

带经纬度和缩放:

http://maps.apple.com/?ll=53.01,6.01&z=15

【讨论】:

    【解决方案2】:

    查看Link

    您可以将此方法与谷歌地图应用程序的 url 方案一起使用。 (comgooglemaps://blahblah)

    [[UIApplication sharedApplication] canOpenURL:(NSURL*)foo]
    

    它将返回 BOOL 值。

    【讨论】:

    • 那是什么语言?这需要在网站上完成,而不是应用程序
    • 检查我写的另一个解决方案
    【解决方案3】:

    试试这个移动谷歌地图并设置路线

    NSString* addr = nil;
         addr = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%1.6f,%1.6f&saddr=Posizione attuale", destinationLat,destinationLong];
    
    NSURL* url = [[NSURL alloc] initWithString:[addr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:url];
    

    【讨论】:

      【解决方案4】:

      试试这个代码

      if ([[UIApplication sharedApplication] canOpenURL:
               [NSURL URLWithString:@"comgooglemaps://"]]) {
              NSString * url = [NSString stringWithFormat:@"%@%@,%@",@"http://maps.google.com/maps?q=",@"75.14524",@"12.1521"];
              [[UIApplication sharedApplication] openURL:
               [NSURL URLWithString:url]];
      
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-02-23
        • 1970-01-01
        • 2015-08-31
        • 1970-01-01
        • 1970-01-01
        • 2015-06-10
        相关资源
        最近更新 更多