从iPhone应用程序启动Google地图应用程序。 [英] Launch Google maps app from iPhone application.

查看:127
本文介绍了从iPhone应用程序启动Google地图应用程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从iPhone应用程序启动Google地图。

启动部分工作正常,但自从iPhone 3.1更新(我认为是在这个时间左右)后,我得到了美国和加拿大的缩小地图,而不是放大在我目前的位置。一切工作正常,但有时更新的东西停止正常工作。



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

  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];

非常感谢任何帮助。



预先感谢。

解决方案

这是我使用的代码在我的一个应用程序中,它可以很好地处理3.1。 Google地图的参数记录在这里

  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发布];
[[UIApplication sharedApplication] openURL:aURL];


I'm trying to launch google maps from my iPhone application.

The launching part works fine but since the iPhone 3.1 update (i think it was around this time) I get a zoomed out map of the US and Canada rather than zoomed in on my current location. Everything worked fine originally but sometime around the update things stopped working correctly.

Here is the string I've been using. This works on my partners phone with iOS 3.0 and our iPod with iOS 2.2.1 but on my phone with iOS 3.1 shows a zoomed out map of Canada and the US.

  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];

Any help is greatly appreciated.

Thanks in advance.

解决方案

This is the code I use in one of my apps and it works fine with 3.1. The parameters for Google maps are 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]; 

这篇关于从iPhone应用程序启动Google地图应用程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆