【问题标题】:mapping current location to destination location in googleMaps在谷歌地图中将当前位置映射到目的地位置
【发布时间】:2011-07-09 18:18:29
【问题描述】:

我的注释上有一个按钮,如下所示调用谷歌地图。 我正在尝试将一条路线从我已知的当前位置映射到从注释记录传递的目标位置。

当前位置无法在谷歌地图中被识别,而是建议一个随机的地方,例如 Current, Dent, Missouri。

- (IBAction)GoogleMap
{
  NSString *mapAddress = [NSString stringWithFormat:@"%@, %@, %@, %@",location.address, location.city, location.state, location.zipcode];

  NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=Current+Location&daddr=%@",  
                 // 40.7406578, -74.0020894, test coordinates
                 [mapAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

}

知道我在哪里出错了吗?这不应该吗?谢谢。

【问题讨论】:

    标签: iphone ios4 google-maps nsurl


    【解决方案1】:

    据我所知,在 Google 地图中输入“当前位置”实际上不会将您带到您当前的位置。

    我建议使用 the method from this SO question 获取您当前的位置,然后将坐标从 CLLocation 对象传递到 Google 地图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 2016-03-07
      • 2016-04-29
      相关资源
      最近更新 更多