2011-07-09 62 views
1

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

当前位置无法在谷歌地图中被识别,而是建议一个随机的地方,如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]]; 

}

任何想法,我错了吗?如果这不起作用?谢谢。

回答

0

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

我建议使用the method from this SO question来获取当前位置,然后将CLLocation对象的坐标转换为Google地图。

+0

奇怪这是如何在iPhone上正常工作,但不是在iPad上。 – Jeremy