3
我不明白为什么当前的位置圈不会出现。我有自定义注释,显示得很好......并且地图被带到用户的当前位置......但是,该圆圈并未出现。MapKit用户位置(蓝点和圆圈)不会显示
这是我的代码。提前致谢!
- (void)viewDidLoad {
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
[mapView setMapType:MKMapTypeStandard];
mapView.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.span.longitudeDelta = 0.005;
region.span.latitudeDelta = 0.005;
[mapView setRegion:region animated:YES];
[mapView setDelegate:self];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D loc = [newLocation coordinate];
[mapView setCenterCoordinate:loc];
}
-(MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *AnnotationViewID = @"annotationViewID";
MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if (annotationView == nil) {
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
}
annotationView.canShowCallout = YES;
if ([annotationView.annotation.title isEqualToString:@"One"]) {
UIImage *pinImage = [UIImage imageNamed:@"one.png"];
[annotationView setImage:pinImage];
}
if ([annotationView.annotation.title isEqualToString:@"Two"]) {
UIImage *pinImage = [UIImage imageNamed:@"two.png"];
[annotationView setImage:pinImage];
}
annotationView.annotation = annotation;
return annotationView;
}
你的设备或模拟器测试?在模拟器中,用户的位置总是在加利福尼亚州的库比蒂诺。 – ezekielDFM 2010-12-22 20:48:45
显示您的viewForAnnotation方法。 – Anna 2010-12-22 20:55:56