views:

172

answers:

2

HI, Does anyone know that how to convert IPHONE:37.615319,-122.388293 ( I am guessing that is the longitude and latitude of the location) in Twitter to real life location? Is there an API available ?

Thanks very much, Ling

+3  A: 

If you are looking for a street address near the lat/long pair, it is called "reverse geocoding".

You may want to look at these services. http://code.google.com/apis/maps/documentation/services.html#ReverseGeocoding http://www.geonames.org/export/reverse-geocoding.html

Chetan Sastry
Thanks very much Chetan, I really appreciate your help.I have another question: the information Iphone:37.615319,-122.388293 in the twitter, does it mean the longitude,latitude or not? how can I confirm this information?Thanks,Ling
LingAi
Yup, `37.615319,-122.388293` is long,lat. And this is the location: http://maps.google.com/maps?oi=map-)
Douwe Maan
Actually it's lat,long. Latitude ranges -90...+90, longitude -180...+180. You can type "37,-122..." into maps.google.com to see where it is.
progrmr
well, I am just afraid that it might not be the longitude/latitude that Iphone uses, do you have any Ihone docs to prove that?
LingAi
Your comment doesn't make any sense. You can see from my answer that it is just an api call, which doesn't order the arguments.
Paul Lynch
Thanks Paul Lynch, I think I confused you before, please ignore it. Thanks for your help.
LingAi
+3  A: 

iPhoneOS has reverse geocoding built in. See code sample below; MKPlacemark contains standard address values; see MKReverseGeocoderDelegate docs to implement the fail delegate method as well.

MKReverseGeocoder  *reverseGeocoder =
[[[MKReverseGeocoder alloc] initWithCoordinate:mapView.userLocation.location.coordinate] autorelease];
reverseGeocoder.delegate = self;
[reverseGeocoder start];

...

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
    NSLog(@"%@", placemark);
}

The argument is a coordinate, which means a CLLocationCoordinate2D structure. This is declared as:

typedef struct {
   CLLocationDegrees latitude;
   CLLocationDegrees longitude;
} CLLocationCoordinate2D;
Paul Lynch
Hi Paul, Thanks so much for your information.
LingAi