我想知道为什么这不起作用,因为网上有很多示例,它们准确地显示了如何打开 map 应用程序以及如何显示从起点到终点的路线的语法。
但无论如何,这就是我想做的:
在我的应用程序中,我有一个按钮,按下该按钮时,应打开 map 应用程序并显示从 A 到 B 的路线。到目前为止,一切都很好。 唯一的是,我的起点是我在 x/y 坐标中的实际位置,我的终点是一个地址。 所以我尝试形成这样的网址:
http://maps.google.com/maps?daddr=Mariahilferstraße+123+1000+Wien&saddr=43.213646,11.491927
map 应用程序应该打开的代码是这样的:
UIApplication *app = [UIApplication sharedApplication];
NSMutableString *url = @"http://maps.google.com/maps?daddr=Mariahilferstraße+123+1000+Wien&saddr=43.213646,11.491927";
[app openURL:[NSURL URLWithString:url]];
map 应用程序打不开......
任何人都可以看到这里的问题并可以帮助我吗?
非常感谢!
最佳答案
对于地理编码器(是一个简单的地理编码器,不是我评论的反向,反向是为了获取纬度/日志形式的地址)
[fgeo geocodeAddressString:@"Boston, MA"
completionHandler:^(NSArray *placemarks, NSError *error){
// Make sure the geocoder did not produce an error
// before continuing
if(!error){
// Iterate through all of the placemarks returned
// and output them to the console
for(CLPlacemark *placemark in placemarks){
NSLog(@"%@",[placemark description]);
}
}
else{
// Our geocoder had an error, output a message
// to the console
NSLog(@"There was a forward geocoding error\n%@",
[error localizedDescription]);
}
}
];
关于iOS打开谷歌地图路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12421589/