[英]Remove a specific annotation from mapview
在地图视图中,我正在创建图钉,例如cafe
, bar
, night_club
和restaurant
。 我该如何编码才能仅删除特定的地点,例如cafe
。 我已使用下面的代码成功删除了所有注释。 我不知道如何删除一个特定的(而不是全部删除)。
for (id<MKAnnotation> annotation in routeMapView.annotations)
{
if ([annotation isKindOfClass:[MapPoint class]])
{
[routeMapView removeAnnotation:index=annotation];
}
}
它可能会帮助您,请尝试使用此功能。
for (id annotation in mapView.annotations)
{
if ([[annotation title] isEqualToString:@"cafe"])
[self.mapView removeAnnotation:annotation];
}
您可以将NSPredicate用于以下情况
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"pinName == %@", @"Cafe"];
[myMapView removeAnnotations:[myMapView.annotations filteredArrayUsingPredicate:predicate]];
上面将删除所有名为cafe的注释。
有关更多信息,您可以看到此答案删除具有特定pinColor的MKMapView注释?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.