Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MGLMapView should map annotation IDs to annotation metadata #3159

Closed

Description

@1ec5

MGLMapView holds an NSMapTable mapping MGLAnnotation objects to dictionaries containing IDs and other metadata. The problem is that IDs aren’t metadata; they’re the unique key. So many operations that should be simple lookups end up requiring expensive loops or are simply impossible. For example, this loop through all annotation metadata can be very expensive, and it isn’t possible to put a fix for #1504 in there because a) we’re iterating over all the annotations, not just the nearby ones, and b) the annotation ID is inaccessible.

I ran into this issue while working on #1496 and again while trying to port the fix for #1504 back from OS X to iOS. For the OS X version of MGLMapView in #3135, I started out with a mapping from annotation IDs (MGLAnnotationTag) to annotation context objects, and it has worked out very well. There are couple places where I need to get an ID from an annotation, and performance is fine in those places.

/cc @incanus

Activity

  1. added
    iOS
    performance
    on Dec 1, 2015
  2. self-assigned this
    on Dec 1, 2015
  3. added this to the ios-v3.1.0 milestone on Dec 1, 2015
  4. added 2 commits that reference this issue on Dec 11, 2015
    198b85a
    a36054e
  5. t-yoshii commented on Jan 25, 2016

    @t-yoshii

    After this change, removeAnnotation() and removeAnnotations() of MGLMapView crashes when annotation has not been added, with following assertion.

    NSAssert(annotationTag != MGLAnnotationTagNotFound, @"No ID for annotation %@", annotation);

    I think removeAnnotation can be called whether the annotation is added or not.

  6. 1ec5 commented on Jan 25, 2016

    @1ec5
    ContributorAuthor

    Thanks, @t-yoshii. Fixed in #3685.

  7. t-yoshii commented on Jan 25, 2016

    @t-yoshii

    Thank you for your quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

iOSperformancerefactor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions