Possible Duplicate:
Convert iPhone GPS to address
hi,how to find address using latitude and longitude in iphonei
This is called "reverse geocoding". Here is a sample:
http://www.icodeblog.com/2009/12/22/introduction-to-mapkit-in-iphone-os-3-0-part-2/
import
#import "JSON.h"
I'm using json framework from http://code.google.com/p/json-framework download that.
+(NSString *) getLocation:(double) lattitude logitude:(double) longitude
{
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",lattitude,longitude];
NSURL *urlFromString = [NSURL URLWithString:urlString];
NSStringEncoding encodingType = NSUTF8StringEncoding;
NSString *reverseGeoString = [NSString stringWithContentsOfURL:urlFromString encoding:encodingType error:nil];
NSDictionary *locationResult = [reverseGeoString JSONValue];
NSString *status = (NSString *)[locationResult objectForKey:@"status"];
NSString *retVal = nil;
if([status isEqualToString:@"OK"])
{
NSArray *results = [locationResult objectForKey:@"results"];
if([results count] > 0)
{
NSDictionary *address=[results objectAtIndex:0];
retVal = [address objectForKey:@"formatted_address"];
}
}
return retVal;
}
you can do this in 2 ways
1) CellIdentifier iphone example, its easy.
2) use a google map service from iphone, which can convert your address to Longitude and latitude here is the link
http://maps.google.com/maps/geo?q=###ADDRESS###&;output=###OUTPUT###&;key=###KEY###
Regards Shahid
精彩评论