Search code examples
objective-ciosios4

Google Map Routing Syntax


can someone please explain to me how does the syntax looks like if I wanna write the google map routing?

http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino

Let say now I dont want use places' name as my input, I have source/destination coordinate, how should I put it?

For example: Destination coordinate = (12,32) Source coordinate = (32, 24)

   http://maps.google.com/maps?daddr=12,32,saddr=32,34

But the above code doesn't work.


Solution

  •  NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",32.0,24.0,12.0,32.0];
    

    In general terms:-

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