iPhone谷歌地图-使用经纬度获取方向

7

我正在开发 iPhone 应用程序。 我知道我的当前位置(纬度和经度)以及目标位置的(纬度和经度)。 如何使用“谷歌地图”查找方向。谷歌地图的 URL 类似于“http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino
从上面的 URL 中,我想使用纬度和经度而不是源和目标地点。怎么办?

3个回答

14
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
                                            currentLocation.coordinate.latitude, currentLocation.coordinate.longitude, 
                                            destLocation.coordinate.latitude, destLocation.coordinate.longitude];

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

2

0

你试过将纬度和经度直接作为参数输入吗?在我的经验中,Google API对于你可以输入什么内容相当宽松。例如,Google Local API几乎可以接受任何东西,包括将纬度和经度作为查询。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接