简体   繁体   中英

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:

[[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. I want open Google map API with my route. There is a maps:// or other things?

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

Edit: your URL looks correct. Looks like you are testing on Simulator! GoogleMaps app is only available on device!

Try this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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