MKReverseGeocoder не отвечает должным образом - PullRequest
0 голосов
/ 07 декабря 2011

Я использую набор карт в своем приложении .... Я пытаюсь поставить метку в определенном месте .... Но геокодер не отвечает должным образом .... Вот код: Map.h

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <MapKit/MKAnnotation.h>
#import <MapKit/MKReverseGeocoder.h>

@interface Map : UIViewController <MKMapViewDelegate,MKReverseGeocoderDelegate>
{
    MKMapView *map;
    MKReverseGeocoder *geoCoder;
    MKPlacemark *mPlacemark;
    IBOutlet UISegmentedControl *mapType;
  }
- (IBAction)changeType:(id) sender;
@end

Map.m

     #import "Map.h"

@implementation Map

 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    map=[[MKMapView alloc]initWithFrame:CGRectMake(0, 40, 320, 379)];

    map.delegate=self;
    map.showsUserLocation=TRUE;
    map.mapType=MKMapTypeStandard; 
      /*Location*/
    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta=0.9;
    span.longitudeDelta=0.9;

    CLLocationCoordinate2D location=map.userLocation.coordinate;

    location.latitude=45.08568;
    location.longitude=77.000;
    region.span=span;
    region.center=location;
    /*Geocoder Stuff*/

    geoCoder=[[MKReverseGeocoder alloc] initWithCoordinate:location];
    geoCoder.delegate=self;
    [geoCoder start];


    [map setRegion:region animated:TRUE];
    [map regionThatFits:region];
    [self.view insertSubview:map atIndex:0];      
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{

    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{
    NSLog(@"%@Reverse Geocoder Errored",[error description]);
    [geoCoder autorelease];
    [geoCoder setDelegate:nil];

}

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
    NSLog(@"Reverse Geocoder completed");
    mPlacemark=placemark;
    [map addAnnotation:placemark];
}

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
    MKPinAnnotationView *annView=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
    annView.animatesDrop=TRUE;
    return annView;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

Здесь Goecoder не отвечает должным образом ... Сбой с ошибкой .... Любые предложения ????

Здесьтакое ошибка Описание

Error Domain=NSURLErrorDomain Code=-1011 "The operation couldn’t be completed. (NSURLErrorDomain error -1011.)" UserInfo=0x5a36270 {PBHTTPStatusCode=503}Reverse Geocoder Errored
...