简体   繁体   English

iPhone:如何从您的应用程序在Google Maps API中启动路线

[英]Iphone: how to launch a route in google maps api from your application

I have read a lot of topics, but i don't find when i want 我读了很多话题,但是我什么时候都找不到

I want to launch google map api from my application with that: 我想从我的应用程序中启动google map api:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://maps.google.com/maps?saddr=41.029598,28.972985&daddr=41.033586,28.984546"]]

But it's open safari with Google maps page. 但这是带有Google地图页面的开放式野生动物园。 I want open Google map API with my route. 我想用自己的路线打开Goog​​le map API。 There is a maps:// or other things? 有maps://或其他东西吗?

Thanks for help !!! 感谢帮助 !!!

Try this 尝试这个

    UIApplication *app = [UIApplication sharedApplication];

    NSURL *url = [[NSURL alloc] initWithString: @"http://maps.google.com/maps?saddr=41.029598,28.972985&daddr=41.033586,28.984546"];

    [app openURL:url];

    [url release];

have a look at the Apple URL Scheme Reference for MapLinks 看看Apple URL Scheme Reference for MapLinks

Edit: your URL looks correct. 编辑:您的网址看起来正确。 Looks like you are testing on Simulator! 看来您正在模拟器上测试! GoogleMaps app is only available on device! GoogleMaps应用仅在设备上可用!

Try this 尝试这个

NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?&saddr=%@ &daddr=%@",sourceaddress,destinationaddress];
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM