gpt4 book ai didi

iphone - MapKit 用户位置(蓝点和圆圈)将不会显示

转载 作者:行者123 更新时间:2023-12-03 19:26:16 25 4
gpt4 key购买 nike

我不明白为什么当前位置圆圈不会出现。我有自定义注释,看起来很好...并且 map 被带到用户的当前位置...但是,圆圈​​没有出现。

这是我的代码。提前致谢!

- (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;

}

最佳答案

将其添加到 viewForAnnotation 方法的顶部:

if ([annotation isKindOfClass:[MKUserLocation class]])
return nil; //return nil to use default blue dot view

关于iphone - MapKit 用户位置(蓝点和圆圈)将不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4513398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com