我在我的应用程序中使用地图套件....我正在尝试将地标放在特定位置......但是地理编码器没有正确响应.... 这是代码: 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