ios - 从 iPhone 应用程序启动 Google map 应用程序。

标签 ios iphone objective-c google-maps uiapplication

我正在尝试从我的 iPhone 应用程序启动谷歌地图。

启动部分工作正常,但自从 iPhone 3.1 更新(我想是在这个时候)我得到了一张缩小的美国和加拿大 map ,而不是放大我当前的位置。最初一切正常,但有时在更新前后一切都停止正常工作。

这是我一直在使用的字符串。这适用于我的合作伙伴的 iOS 3.0 手机和我们的 iOS 2.2.1 的 iPod,但在我的 iOS 3.1 手机上显示加拿大和美国的缩小 map 。

  NSString *name = @"clothing";
NSString *latlong = [[NSString alloc] initWithFormat:@"%@,%@", latitudeString, longitudeString];

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%@&mrt=yp&ll=%@",
                      [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
                      [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

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

非常感谢任何帮助。

提前致谢。

最佳答案

这是我在 one of my apps 中使用的代码它适用于 3.1。 Google map 的参数是 documented here .

CLLocationCoordinate2D stationLocation = ...

NSString *urlString = [[NSString alloc]
     initWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d",
        curLocation.latitude,
        curLocation.longitude,
        stationLocation.latitude,
        stationLocation.longitude];

NSURL *aURL = [NSURL URLWithString:urlString];
[urlString release];
[[UIApplication sharedApplication] openURL:aURL]; 

关于ios - 从 iPhone 应用程序启动 Google map 应用程序。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1563880/

相关文章:

ios - 如何检查代码是否在iPhone设备或 watch 设备上执行?

objective-c - Objective C 类型作为参数

ios - [NSURLConnection sendAsynchronousRequest : . ..] 总是发送完成 block 吗?

ios - 当单元格向左滑动时,在“警报 View ”中显示行号。在界面生成器中添加了滑动手势

ios - Parse.com 用户在离线时注销

ios - 如何在iOS中使用AUMatrixMixer

iphone - 无效的应用程序二进制文件

iphone - 简单,没有多余的装饰,在 iPhone 中获取 LAT/LON

iphone - 切换选项卡(最初)非常慢 - 将功能移出 viewDidLoad?

iphone - 如何正确停止和恢复 CADisplayLink?