MGLAnnotationImage reuseIdentifier should not be mandatory and should be common to several annotations.
Internal code shows that this identifier is deeply linked to the annotation sprite and annotation itself. For the moment it is not possible to add several annotation with the same annotation image.
The mapView does not handle a bucket of unused annotation images for the dequeueReusableAnnotationImageWithIdentifier: method.
For the moment it is not possible to add several annotation with the same annotation image.
Can you clarify? There can certainly be multiple annotations associated with the same instance of MGLAnnotationImage. If -addAnnotations: encounters a reuse identifier that鈥檚 already being used for another annotation, it avoids installing the same image, so the image data is only decoded once.
That said, the reuse identifier should be optional; we鈥檇 implement that by generating a unique identifier for the annotation image behind the scenes.
The bug is that the reuse identifier is currently assumed to uniquely identify an annotation image, and an that annotation image always looks the same on every annotation it鈥檚 associated with at a given time. These assumptions are consistent with the way core mbgl code uses icon names, but they鈥檙e inconsistent with MKAnnotationView, which is what MGLAnnotationImage was intended to imitate.
ok, so the workaround is to use reuseIdentifier = imageName, right?
Correct.
So this is not going to be fixed @1ec5? If not, the method comments need to be updated because those of us coming from MapKit do not expect the currently implemented behavior.
It would be great to fix this. But we either need to figure out a way to implement the expected behavior atop GL sprites, which expect to uniquely identify images by name, or we need to implement view-based annotations as proposed in #1784.
I would prefer a documentation change (e.g., reuseIdentifier is uniquely associated with an image sprite) or method signature change (e.g., dequeueReusableAnnotationImageWithName: and annotationImageWithName:) for this issue and focus all work on implementing view-based annotations.
This is just 100% wrong. This is completely antithetical to the concept of reuse pools on iOS. Just plain wrong. I just spent way too long discovering this issue first hand. I'm quite frankly surprised that this has been open this long.
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.
/cc @fabian-guerra
Thanks for re-opening. Hope to see some movement on this at some point.
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.
Most helpful comment
This is just 100% wrong. This is completely antithetical to the concept of reuse pools on iOS. Just plain wrong. I just spent way too long discovering this issue first hand. I'm quite frankly surprised that this has been open this long.