因此,我使用集群库对注释进行分组,其中有一个小错误,当地图完全放大时,一些非常接近的注释可能会出现分组。由于这是一个框架,我不能直接做很多事情,但如果地图完全放大,我可以禁用所有分组。问题是我找不出一个可靠的方法来做这件事。
regionDidChangeAnimated
这是理想的代码,我想检查地图是否完全放大(到你不能再放大的程度)。
func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
NSOperationQueue().addOperationWithBlock {
let scale: Double = Double(self.map.bounds.size.width) / self.map.visibleMapRect.size.width
let annotations = self.clusteringManager?.clusteredAnnotationsWithinMapRect(self.map.visibleMapRect, withZoomScale: scale)
self.clusteringManager?.displayAnnotations(annotations, onMapView: self.map)
}
}
我试过检查
mapView.region.span
属性,但我相信这将根据屏幕大小等而改变。。。
有什么建议吗?提前谢谢。