目前为止,我使用以下代码从我的应用程序成功地通过 Maps 应用生成方向:
NSString *formattedGroceryAddress = [[NSString stringWithFormat:@"%@",((EnhancedUIActionSheet *)actionSheet).grocery.address] stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSString *routeString = [NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",localDataHelper.userLocation.coordinate.latitude,localDataHelper.userLocation.coordinate.longitude,formattedGroceryAddress];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:routeString]];
它会打开适当的 "驾车" 方向指示,但我想默认情况下用 "步行" 方向来打开地图。也许我可以在请求中传递另一个参数来实现这一点。 有人知道怎么做吗?谢谢!