扩展的mapView:viewForAnnotation现在没有蓝点

发布于 2024-09-18 06:04:55 字数 723 浏览 2 评论 0原文

我使用以下代码扩展了 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 的内置蓝点。您可以看到我消除了为点绘制的自定义图像,但我不知道如何使其显示为默认值。

I have extended MapKit's ability to draw custom annotation images with the following code:

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

My question is what should I make view = to in order to retain the iPhone's built in blue dot. You can see that I eliminate my custom image being drawn for the dot, but I don't know how to make it show as default.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩套路吗 2024-09-25 06:04:55

不要在其他地方放任何东西。我进行以下检查。我认为这是来自苹果示例代码。

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

Don't put anything in the else. I do the following check. I think this is derived from Apple sample code.

- (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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文