2013-04-30 94 views
2

在我的mapview中,我创建了像cafebarnight_clubrestaurant的引脚。我如何编码以仅删除特定点,例如cafe。我已经使用下面的代码成功删除所有注释。我无法弄清楚如何删除一个特定的(而不是全部)。从mapview中删除特定的注解

for (id<MKAnnotation> annotation in routeMapView.annotations) 
{ 
    if ([annotation isKindOfClass:[MapPoint class]]) 
    { 
    [routeMapView removeAnnotation:index=annotation]; 
    } 
} 
+0

如何üü添加注释[R ..? – 08442 2013-04-30 13:36:51

+0

你的PIN是如何创建的?你是否为每种针类型(咖啡,酒吧等)制作课程,还是给他们标签? – Malloc 2013-04-30 13:41:44

+0

我亲爱的,你有答案吗? – 2013-05-01 06:06:27

回答

3

它可以帮助您,请尝试使用这一个。

for (id annotation in mapView.annotations) 
{ 
    if ([[annotation title] isEqualToString:@"cafe"]) 
      [self.mapView removeAnnotation:annotation]; 
} 
1

可以使用NSPredicate为情状

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"pinName == %@", @"Cafe"]; 
[myMapView removeAnnotations:[myMapView.annotations filteredArrayUsingPredicate:predicate]]; 

以上将删除所有命名的咖啡馆的注解。

欲了解更多信息,你可以看到这个答案 Remove MKMapView Annotations with a certain pinColor?