How to open a apple maps application with directions from my ios application

前端 未结 2 1048

My aim is to open a map application from ios application with directions, I am able to open maps application but it is not showing directions, i have written the code as follows

2条回答
  •  独厮守ぢ
    2021-02-09 14:01

    If you mean taking the user to the maps application based on two points, then you can do it like this:

    Create an NSURL that looks like this:

    NSURL *URL = [NSURL URLWithString:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"];
    

    You plug in your starting address and destination (in lat. and long.) appropriately. Tell your application to open the URL

    [[UIApplication sharedApplication] openURL:URL];
    

    It should take you to the maps application automatically!

提交回复
热议问题