繁体   English   中英

显示当前位置MKMapView

[英]shows the current location MKMapView

我已经设置好了,以便我的MKMapView显示当前位置。 我还为其他引脚实现了自定义引脚。 但是,事实证明当前位置显示为自定义图钉,而我只是希望它是一个常规的蓝色圆圈(如google地图所具有的)。

我在代码中定义了以下内容:

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"];
    if (pin == nil)
    {
        pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease];
    }
    else
    {
        pin.annotation = annotation;
    }

    [pin setImage:[UIImage imageNamed:@"TestPin.png"]];
    pin.canShowCallout = YES;
    pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    return pin;
}

如何防止当前位置显示为大头针?

尝试这个 :-

- (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation:(id<MKAnnotation>) annotation
{        
    if (annotation == mapView.userLocation)
    {
       return nil;
    }
    else
    {
       MKAnnotationView *pin = (MKAnnotationView *) [self.mapView dequeueReusableAnnotationViewWithIdentifier: @"VoteSpotPin"];
       if (pin == nil)
       {  
          pin = [[[MKAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"TestPin"] autorelease];
       }
       else
       {
          pin.annotation = annotation;
       }           

       [pin setImage:[UIImage imageNamed:@"TestPin.png"]];
       pin.canShowCallout = YES;
       pin.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
       return pin;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM