gpt4 book ai didi

mapkit - 扩展 map View :viewForAnnotation Now No Blue Dot

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

我使用以下代码扩展了 MapKit 绘制自定义注释图像的能力:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
NSLog(@"Drawing a cloud on the map");
MKAnnotationView *view;
if(annotation != mapView.userLocation){
view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
view.image=[UIImage imageNamed:@"placemarkCloud.png"];
[view setCanShowCallout:YES];
[view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]];
}
else{
view=
}
return view;
}

我的问题是我应该怎样设置 view = 以保留 iPhone 的内置蓝点。您可以看到我消除了为点绘制的自定义图像,但我不知道如何使其显示为默认值。

最佳答案

不要在 else 里放任何东西。我做以下检查。我认为这是源自 Apple 示例代码。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{

if ([annotation isKindOfClass:[MKUserLocation class]]) {
//Don't trample the user location annotation (pulsing blue dot).
return nil;
}

//Continue on to your regular code here.

关于mapkit - 扩展 map View :viewForAnnotation Now No Blue Dot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3686515/

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