-
Notifications
You must be signed in to change notification settings - Fork 1.3k
If there are too many annotation images, some annotation images are invisible #3185
Comments
Oh, good catch. Please feel free to submit a pull request with that functionality. The iosapp demo application loads up to 10,000 points more or less simultaneously, and the only hard limit I’m aware of is |
I think this is a duplicate of #1883. |
I tried using the same reuseIdentifier (and by extension image) and it has no trouble showing as many annotations as I want. Is there a way to disable caching, or whatever the reuse identifier is used for? |
I'm having the same issue. Just built from source (d11d53d). The workaround described in #2693 (comment) is not working for me. It looks like it's the same issue as #1883 or #2956. I'm clustering around 16k annotations and only show 16 annotations at the same time, which are removed and added every time the map region changes. Everything works fine when using a single image with a single reuse id. But when I'm using unique reuse ids, annotations start disappearing. |
Tried to debug this some more. The problem only seems to exist when there are a lot of different reuse ids. It doesn't matter if the image is drawn using |
FWIW, I'm able to reproduce this as well. Some observations:
Let me know if anyone has found a workaround. |
I've got a sample project at https://github.com/ChrisLowe-Takor/MapboxAnnotationLimitBug showing this bug. This should be a 20x20 grid of numbered annotations. As @JohnRbk mentioned I've played around with it a little and found that using smaller graphics increases the number of custom annotations that can be shown (over 100 in this demo, whilst my app bombs out around 30). |
The root cause of this bug is #489. The sprite image data is still present, which is why hit testing continues to work. However, the @jfirebaugh @ansis, can we at least increase the limit to 1024×1024 to mitigate #489? |
Unfortunately, #3530 exacerbates this bug. Now that sprites in the SpriteAtlas are unscaled, on a 2× display, we’re only able to squeeze in something like a fourth of the sprites. Even the “Add 100 Points” demo runs up against the limit: |
@1ec5 Can you elaborate? It seems like the only case in which #3530 would exacerbate this bug was if you were supplying lots of |
We can set debug::spriteWarnings to true to troubleshoot this. It will spew out a warning for SpriteAtlas overflow. IMHO, we should change the default value of this to true since it can happen even without annotations (Its more serious in that case since the map will silently be missing some icons). |
@jfirebaugh, my bad, this regression wasn’t caused by #3530; I simply misremembered, expecting the 100 points to be distributed in the same way as in the 10,000-point demo. In fact, the stock demos are fine, and the steps in #3185 (comment) reproduce exactly as before: Sorry for the false alarm. |
My project is severely hampered by this bug so I'll put my 2c.
- (void) mapView:(MGLMapView *)mapView didFailToAllocationAnnotationImage: (id<MGLAnnotation) annotation
|
#3703 increases the SpriteAtlas size to 1024×1024. I’m still working on a way for developers to remove annotation images, building off #3146. The main holdup right now is that annotations whose images have been deleted wind up producing “sprite not found” messages in the console (and hurting performance slightly, probably related). So I’m looking at replacing the deleted image with the default image. Failing that, I’ll have MGLMapView automatically remove those annotations and readd them with the default annotation image. |
Added an API for deleting unused annotation images’ images. When you nil out the image of an MGLAnnotationImage, MGLMapView deletes the sprite from the style and recreates any annotation associated with the MGLAnnotationImage instance; the MGLAnnotationImage’s falls back to SDK’s default annotation image. In iosapp, deselecting an annotation resets its image to the default; deselecting it again restores the image. ref #3185
Just ran into this issue, even though we add and remove annotations as need when the map region changes. |
Added an API for deleting unused annotation images’ images. When you nil out the image of an MGLAnnotationImage, MGLMapView deletes the sprite from the style and recreates any annotation associated with the MGLAnnotationImage instance; the MGLAnnotationImage’s falls back to SDK’s default annotation image. In iosapp, deselecting an annotation resets its image to the default; deselecting it again restores the image. ref #3185
Added an API for deleting unused annotation images’ images. When you nil out the image of an MGLAnnotationImage, MGLMapView deletes the sprite from the style and recreates any annotation associated with the MGLAnnotationImage instance; the MGLAnnotationImage’s falls back to SDK’s default annotation image. In iosapp, deselecting an annotation resets its image to the default; deselecting it again restores the image. ref #3185
#4801 landed. As of the iOS SDK v3.3.0 alphas, if you run into this issue, you have several recourses:
The bug that this ticket tracks is still present in the SDK, but with these workarounds, this is as far as we expect to take the v3.3.0 milestone. |
have a same issue. ios/swift/mapbox v.3.3.3 i generate many different images on the fly with CGContext for different annotations.
|
Since iOS SDK v3.3.x added view-based annotations, that’s our suggested workaround for use cases that require many unique or large images. You can see a basic implemention example here. There are performance trade-offs, but views are generally more flexible and nicer to work with, anyway. 😉 |
To make sure the loop here is obviously and fully closed: the fix for this issue will be available in iOS 3.7.0, pre-releases of which are available now. |
My use case:
I have 19,000 annotations spread across the US.
Each annotation has a unique image.
I only show 20 annotations at a time as the user pans.
Problem:
After panning for awhile and loading a few hundred annotations (not all at once), it fails to show any more.
Here is how I remove and add annotations as the user pans:
To be clear, the imageForAnnotation method fires, and a valid MGLAnnotationImage (inited with UIImage and a unique reuseIdentifier) is returned. However, the annotations stop showing up on the map.
The text was updated successfully, but these errors were encountered: