DEPRECATED-mapbox-ios-sdk icon indicating copy to clipboard operation
DEPRECATED-mapbox-ios-sdk copied to clipboard

RMPointAnnotation is losing its custom image upon a view controller presentation

Open hasanadil opened this issue 11 years ago • 9 comments

Hi, I'm setting a custom image for my RMPointAnnotation annotations, they show up fine as I add annotations. However, when my controller (which contains the mapView) presents a view controller, using a custom presentation transition, the annotation images are removed and the default annotation icon (the blue balloon) shows instead. Then if I add another annotation, the new annotation shows my custom image as expected.

Thanks for the help.

hasanadil avatar Jun 26 '14 15:06 hasanadil

@hasanadil Can you upload or share some sample code? I think some of this would depend upon the nature of your presentation transition as well as your -viewDidLoad / viewWillAppear: / viewDidAppear: setup and delegate callback.

incanus avatar Jun 27 '14 18:06 incanus

Sure, this is a video of the problem http://www.screencast.com/t/xbgXSC3ksxC4

Presenting the controller on top of the map: https://gist.github.com/hasanadil/cddabfecc79d08596699

This transition controller for the animation is https://gist.github.com/hasanadil/47e97ab56b5273b8a90e

Looks like the annotations lose their image on a redraw just before the controller presentation starts.

hasanadil avatar Jun 28 '14 14:06 hasanadil

Hmm, I think based on the greying that it might be tintColor-related. Looking again at the code for tint color changing, this looks suspect:

https://github.com/mapbox/mapbox-ios-sdk/blob/f47ae3d96a27661eb4f888660787bffdf0294492/MapView/Map/RMMapView.m#L2673-L2686

I think there's a bug in that it doesn't take into account custom imagery for RMPointAnnotation objects.

Can you try commenting that out and see if it changes behavior?

Also, I think this routine should take tintAdjustmentMode into account.

incanus avatar Jun 30 '14 17:06 incanus

Hi, yep that was it!

Commenting it out and it worked. Added this additional conditional to see if the layer has any contents then don't remove it.

Line 2678

        if ([annotation isKindOfClass:[RMPointAnnotation class]] && annotation.isAnnotationVisibleOnScreen)
        {
            if (![[annotation layer] contents]) {
                [annotation.layer removeFromSuperlayer];
                annotation.layer = nil;
                [_overlayView addSublayer:annotation.layer];
                updatePoints = YES;
            }
        }

hasanadil avatar Jun 30 '14 17:06 hasanadil

I'm trying to recall what the thought process here. It does mean to remove, then re-add points. But I think the code predates the ability to set a custom image on an RMPointAnnotation, meaning that it would go from a default marker (using the map's tintColor) to a default grey marker. I think we will probably just end up removing this tinting behavior. I'll leave this open as a bug ticket.

incanus avatar Jun 30 '14 17:06 incanus

I see, it would have to keep state of the icon/image for each annotation that was removed.

hasanadil avatar Jun 30 '14 17:06 hasanadil

It's also happening when annotations go off the viewable bounds of the map scroll view. Upon seeing the annotation again, I see the default icon instead of the custom annotation image.

Thanks

hasanadil avatar Jul 03 '14 13:07 hasanadil

Accidentally closed it..

hasanadil avatar Jul 03 '14 13:07 hasanadil

No activity for a year and I'm still seeing this behavior or something like it.. bump ?

ZavenArra avatar Sep 09 '15 03:09 ZavenArra