是否可以强制MapKit在不聚类的情况下显示所有注释? [英] Is it possible to force MapKit to show all annotations without clustering?

查看:92
本文介绍了是否可以强制MapKit在不聚类的情况下显示所有注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个都符合MKAnnotation的类,我想知道,有没有一种方法可以强制MapKit在用户缩小并显示所有注释时不将注释聚类?

I have two classes that both conform to MKAnnotation, and I was wondering, is there a way to force MapKit to not cluster the annotation when a user zooms out and display all annotations?

推荐答案

将MKAnnotation的clusteringIdentifier设置为nil.

Set MKAnnotation's clusteringIdentifier to nil.

例如

class BikeView: MKMarkerAnnotationView {

    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override var annotation: MKAnnotation? {
        willSet {
            if let bike = newValue as? Bike {
                clusteringIdentifier = nil
            }
        }
    }
}

这篇关于是否可以强制MapKit在不聚类的情况下显示所有注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆