2012-01-27 13 views
5

मेरे पास रिवर्स जियो-कोडिंग से संबंधित एक प्रश्न है।उद्देश्य सी दिए गए निर्देशांक के प्लेसमार्क कैसे प्राप्त करें

मेरे ऐप में, मेरे पास कुछ निर्देशांक हैं (मेरे वर्तमान निर्देशांक नहीं) और मैं उन्हें प्लेसमार्क में रूपांतरित करना चाहता हूं। मैंने कई वेबसाइटें और कोड खोले हैं लेकिन वे सभी मौजूदा स्थान के रिवर्स जियोकोडिंग के बारे में हैं ...

क्या निर्दिष्ट निर्देशांक (जो वर्तमान स्थान नहीं हैं) के प्लेसमार्क प्राप्त करने का कोई तरीका है?

और यदि वहां है, तो कृपया मुझे कुछ कोड या संदर्भों में मदद करें।

+0

के प्रतिनिधि तरीकों आप क्या मतलब है? आपको वही करना होगा कि स्थान आपका है या नहीं। यदि आप आईओएस 5 के लिए विकास कर रहे हैं तो यहां कुछ संदर्भ दिया गया है: http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class – vakio

+0

आप CLLocation.coordinat.longitude या अक्षांश को स्थान असाइन नहीं कर सकते हैं। और रिवर्स जीओकोडिंग विधि केवल CLLocation स्वीकार नहीं करता है CLLocationCoordinate2D – Garnik

+2

'CLLocation * loc = [[CLLocation alloc] initWithLitudeitude: अक्षांश देशांतर: देशांतर];' – vakio

उत्तर

2

आप दो तरह से इस लक्ष्य को हासिल कर सकते हैं: -

सबसे पहले जिस तरह से: - जवाब में Google API

-(void)findAddresstoCorrespondinglocation 
{ 
    NSString *str = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",myCoordInfo.latitude,myCoordInfo.longitude]; 
    NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
    ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; 
    [request setRequestMethod:@"GET"]; 
    [request setDelegate:self]; 
    [request setDidFinishSelector: @selector(mapAddressResponse:)]; 
    [request setDidFailSelector: @selector(mapAddressResponseFailed:)]; 
    [networkQueue addOperation: request]; 
    [networkQueue go]; 

} 

का उपयोग कर आप आपके द्वारा निर्दिष्ट निर्देशांक स्थान के बारे में सभी जानकारी मिल जाएगी जानकारी प्राप्त करें।

द्वितीय कार्य: -

लागू

जियोकोडिंग रिवर्स एक) जोड़ने mapkit ढांचे

ख) ज फ़ाइल में

MKReverseGeocoder *reverseGeocoder; 

MKReverseGeocoder का उदाहरण है)।।। .m फ़ाइल में

self.reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:cordInfo]; 
    reverseGeocoder.delegate = self; 
    [reverseGeocoder start]; 

लागू दो MKReverseGeoCoder

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error 
{ 
    NSLog(@"MKReverseGeocoder has failed."); 
} 

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark 
{ 
    MKPlacemark * myPlacemark = placemark; 
    NSString *city = myPlacemark.thoroughfare; 
    NSString *subThrough=myPlacemark.subThoroughfare; 
    NSString *locality=myPlacemark.locality; 
    NSString *subLocality=myPlacemark.subLocality; 
    NSString *adminisArea=myPlacemark.administrativeArea; 
    NSString *subAdminArea=myPlacemark.subAdministrativeArea; 
    NSString *postalCode=myPlacemark.postalCode; 
    NSString *country=myPlacemark.country; 
    NSString *countryCode=myPlacemark.countryCode; 
    NSLog(@"city%@",city); 
    NSLog(@"subThrough%@",subThrough); 
    NSLog(@"locality%@",locality); 
    NSLog(@"subLocality%@",subLocality); 
    NSLog(@"adminisArea%@",adminisArea); 
    NSLog(@"subAdminArea%@",subAdminArea); 
    NSLog(@"postalCode%@",postalCode); 
    NSLog(@"country%@",country); 
    NSLog(@"countryCode%@",countryCode); 

    } 
+0

बस ध्यान दें: आईओएस 5.0 में, इसे पक्ष में बहिष्कृत किया गया है 'जीएलजीओकोडर' वर्ग का: http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html#//apple_ref/occ/cl/CLGeocoder – Krizz

+0

मैं उपयोग करने का सुझाव दूंगा गूगल एपीआई विधि। यह आसान और अधिक विश्वसनीय है। – Gypsa

+0

धन्यवाद जिप्सा मैं पहले दृष्टिकोण की कोशिश करूंगा लेकिन जैसा कि मुझे पता है कि एमकेआरवीसेजियो कोडर आईओएस 5 में चित्रित है। अग्रिम धन्यवाद – Garnik

संबंधित मुद्दे