Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS 11 MapKit Annotation Clustering

denkeni
April 12, 2018

iOS 11 MapKit Annotation Clustering

denkeni

April 12, 2018
Tweet

More Decks by denkeni

Other Decks in Technology

Transcript

  1. iOS 11 MapKit
    Annotation
    Clustering
    ᪴襊妿涢藳 by @denkeni

    View Slide

  2. View Slide

  3. With Clustering1
    Looks cleaner2.
    2 App Store: CafeFreelance - ૡ֢߅珹記
    1 https://github.com/Nandalu/NDLAnnotationClustering

    View Slide

  4. With 2 types of
    Clustering
    Overlapping looks not so
    good...

    View Slide

  5. iOS 11 Annotation Clustering
    IS OUT!!!

    View Slide

  6. clusteringIdentifier3
    An identifier that determines whether the annotation view participates in
    clustering.
    var clusteringIdentifier: String? { get set }
    The default value of this property is nil, which prevents the
    annotation view from being clustered with other annotation
    views. Setting the property to a non nil value it to participate in
    clustering.
    3 Documentation > MapKit > MKAnnotationView > clusteringIdentifier

    View Slide

  7. View Slide

  8. final class AnnotaionView : MKMarkerAnnotationView {
    override init(annotation: MKAnnotation?, reuseIdentifier: String?) {
    super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
    clusteringIdentifier = "AnnotaionView"
    }
    }
    DID NOT WORK
    (But seems to work now, at latest version)

    View Slide

  9. Working code4
    final class AnnotaionView : MKMarkerAnnotationView {
    override var annotation: MKAnnotation? {
    willSet {
    clusteringIdentifier = "AnnotaionView"
    }
    }
    }
    4 What's New in MapKit, WWDC 2017 - Session 237

    View Slide

  10. On iOS 11.1
    Crash
    rdar://35381219

    View Slide

  11. View Slide

  12. On iOS 11.2
    Crash
    rdar://36131654

    View Slide

  13. View Slide

  14. Summary:
    — Use MapKit Annotation Clustering on iOS 11.3 or later
    — Question, or help5?
    5 https://github.com/Nandalu/Housing

    View Slide