领域 - 在 swift 中过滤集群地图视图

Realm - filtering clustered map view in swift

真的很喜欢 the Realm clustered map view tutorial in Swift 但我想知道是否有办法使用谓词轻松过滤结果?

感谢您的反馈!在您提出问题时,RealmMapView 不提供此功能,但从 v1.7 开始,已添加此功能。

新功能通过 ABFRealmMapView/RealmMapView 上名为 basePredicate 的 属性 发挥作用。您可以使用过滤地图搜索所针对的 Realm 对象的谓词设置此 属性,然后在每次刷新期间将其与地图生成的边界框谓词组合。

例如,在存储库中包含的 Swift demo project 中,地图正在搜索旧金山的餐馆。通过将 basePredicate 设置为:

self.mapView.basePredicate = NSPredicate(format: "name BEGINSWITH 'A'")

地图现在将仅显示旧金山以 'A' 开头的餐馆。