Search code examples
iphoneiosjsoncllocation

find road distance between current location and specified location


I wants calculate the road distance between Current location and the other location. Which (XML/JSON Google direction or anyother) API i use (if any) or what is the right way to do this.?

before i try the following. but i wants road distance

Thanks.

CLLocation *location1 = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1];

CLLocation *location2 = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2];

NSLog(@"Distance in meters: %f", [location1 getDistanceFrom:location2]);

Solution

  • Use google direction Json api You have to provide the intital location detail and final location. Inside the leg array of the json you will get the distance dictionary in which you will have the distance between two locations.