मैं कैसे एक रिवर्स geocode करने के बारे में डेमो के बाद API दस्तावेज़ और डेमो देखा है - एक पते पाने के लिए, एक अक्षांश / देशांतर स्थान दिया। मैं रिवर्स करने की ज़रूरत है। मैं यह सोचते हैं रहा है कि यह पहले से ही समस्या हल हो जाती है क्योंकि एप्पल के MapKit एपीआई यह पूरी तरह से बचा जाता है।
मैं एक CLLocation या एक पते से MKPlacemark कैसे निर्धारित कर सकते हैं?
वोट
2
1 जवाब
वोट 6
6
एक तरह से तो जैसे गूगल वेब सेवा का उपयोग करने के लिए है:
-(CLLocationCoordinate2D) addressLocation {
NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
[addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSLog(@"locationString = %@",locationString);
NSArray *listItems = [locationString componentsSeparatedByString:@","];
double latitude = 0.0;
double longitude = 0.0;
if([listItems count] >= 4 && [[listItems objectAtIndex:0] isEqualToString:@"200"]) {
latitude = [[listItems objectAtIndex:2] doubleValue];
longitude = [[listItems objectAtIndex:3] doubleValue];
/*
NSString *nameString = [NSString stringWithFormat:@"http://ws.geonames.org/findNearestAddress?lat=%f&lng=%f",latitude,longitude];
NSString *placeName = [NSString stringWithContentsOfURL:[NSURL URLWithString:nameString]];
NSLog(@"placeName = %@",placeName);
*/
}
else {
//Show error
}
CLLocationCoordinate2D location;
location.latitude = latitude;
location.longitude = longitude;
return location;
}













