How to use Google Map API in Iphone?

I want to find out how the Google Map API gives us directions.

Create a sample tool where I can use my location as a starting point and choose a different place, and I can view the routes (both driving and walking) in the text and on the map as part of my existing application.

I did not use google map api, so I am absolutely naive about it

Can anyone help me with this?

+4
source share
1 answer

try it,

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

What the code does is it will show the route between your source and destination on the google map.

If you do not have longitude, you can do this: -

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

Hope this helps you. Good coding :)

+2
source

All Articles