Google에서는 단일 기기가 60 초 이내에 한 번만 위치를 검색하도록 허용하지 않으므로 (MKReverseGeocoder *) 지오 코더 didFailWithError 일 때 다른 메소드 (http 요청 대신 JSON이 필요함)로 작업합니다.
4.3.3 (3GS)에서 작동하며 사용자의 위치를 충돌없이 연속적으로 검색하는 30-40 회의 테스트를 거쳤습니다. 도움이 되었기를 바랍니다.
- (void) retrieveCurrentLoc {
self.geoCoder =
[[[MKReverseGeocoder alloc] initWithCoordinate:newLocation.coordinate] autorelease];
geoCoder.delegate = self;
[geoCoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
NSString *fetchURL = [NSString stringWithFormat:@"http://maps.google.com/maps/geo? q=%@,%@&output=json&sensor=true", [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.latitude], [NSString stringWithFormat:@"%f",mapView.userLocation.location.coordinate.longitude]];
NSURL *url = [NSURL URLWithString:fetchURL];
NSString *htmlData = [NSString stringWithContentsOfURL:url];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *json = [parser objectWithString:htmlData error:nil];
NSArray *placemark = [json objectForKey:@"Placemark"];
if ([[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectFor Key:@"ThoroughfareName"] != NULL){
currentAddress = [[[[[placemark objectAtIndex:0] objectForKey:@"AddressDetails"]objectForKey:@"Country"]objectForKey:@"Thoroughfare"]objectFor Key:@"ThoroughfareName"];}
else {
currentAddress = [[placemark objectAtIndex:0] objectForKey:@"address"];
}
}
에서 지오 코더 개체를 해제하지 않았지만 여전히 didFailWithError에서 수행합니다. 이유를 설명 할 수 있습니다 .http : //stackoverflow.com/questions/7443252/at-first-time-mkreversegeocoder-didfailwitherrorer-domain-nsurlerrordomain -c – Srinivas
여기에 있습니다 .. 모든 솔루션 ?? 감사합니다 – Frade
너무 많이 호출해야합니다 http://stackoverflow.com/questions/2941495/mkreversegeocoder-server-returned-error-503 –