Satyam
Satyam

Reputation: 15894

iphone google maps get latitude and longitude of an address

Is there any URL from google maps, that returns me the latitude and longitude of an address. i want to use these lat and long details in iPhone Map kit to plot some information.

Upvotes: 2

Views: 2586

Answers (2)

Ali
Ali

Reputation: 51

This is working for me:

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", 
                      [addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];

good luck

Upvotes: 5

Henrik Erlandsson
Henrik Erlandsson

Reputation: 3831

I don't think there's a built in way to do reverse reverse geocoding, but I'm new to the iPhone, Objective C, Cocoa and XCode, so.

This is the best article I could find on the subject.

Goes in my 'could be good' bookmark drawer :)

The second example URL gives an XML file that you could fetch with initWithContentsOfURL, and then getObjectForKey:@"lat" and getObjectForKey:@"lng" or something along those lines.

Upvotes: 2

Related Questions