如何在可见地图矩形中选择特定类的注释
我正在尝试实现下面的方法,该方法基本上使用当前地图矩形中可见的注释填充我的数组。
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
self.LocationSet = [self.mapView annotationsInMapRect:self.mapView.visibleMapRect];
self.LocationArray = [self.nearbyCarParksSet allObjects];
}
仅选择我想要包含在集合/数组中的某一类注释的正确方法是什么?例如,在当前地图视图中,我可能有属于“餐厅”类、“停车场”类、“加油站”类等的注释,而我只想存储属于“餐厅”类的注释。最好的方法是什么?
I am trying to implement the method below which basically populates my array with the annotations visible in the current map rect.
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
self.LocationSet = [self.mapView annotationsInMapRect:self.mapView.visibleMapRect];
self.LocationArray = [self.nearbyCarParksSet allObjects];
}
What is the right way to select only a certain class of annotations which I want to include in the set/array? For example, in the current map view I might have annotations belonging to a "Restaurant" class, a "carpark" class, a "petrol station" class, etc., and I only want to store annotations belonging to the "Restaurant" class. What is the best approach?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设
locationSet
具有从上述方法中的第一次调用派生的所有注释。您可以使用以下方式获取所有类型的注释:Assuming that
locationSet
has all the annotation derived from the first call in the method above. You can get all annotations of type using,