TSClusterMapView icon indicating copy to clipboard operation
TSClusterMapView copied to clipboard

Annotations going crazy when changing map layout and center

Open zfrankz opened this issue 9 years ago • 8 comments

Hello, I have a "layout changing" map view (changes the height of the view with some user interactions) and those changes (changing map center coordinates as well) make the annotations going crazy, changing their positions and some disappearing!

Screenshots:

https://www.dropbox.com/s/t3kmqytjzl6wtx9/crazy1.png?dl=0

When I select the annotation in the first "O" of London I change the height of the map and on didSelectAnnotationView: delegation method I do [self.theMap setCenterCoordinate:theannotation.coordinate animated:YES];

That's what I have: https://www.dropbox.com/s/hdi2n9nwb848974/crazy2.png?dl=0

As you can see, the annotation has been displaced and any other annotations are gone!

zfrankz avatar Mar 09 '15 15:03 zfrankz

If you could try the code on the Develop branch and see if there's any change to you results. Will look into this further.

ashare80 avatar Mar 09 '15 17:03 ashare80

Hello, I'm testing the new code and I realised that now, when an annotation is selected in the map, the class of this annotation view has changed. For example, if is a clustered one, now is member of my custom clustered class instead of the TSClusterAnnotationView class. I haven't checked the changes on the code but at first instance I thought it was because iOS 8.2 (I updated a device) but I tried in a different one and still happening the same. Are you aware of it? Anyway, I made some changes to adapt my code to that new "feature".

Well, coming back to the issue, now the annotations seem to be not so crazy but, after few times expanding/collapsing a clusterAnnotation, I can see how is "moving" to the left (I think is the #8 issue)

zfrankz avatar Mar 10 '15 12:03 zfrankz

@zfrankz Yes it was pointed out to me that the TSClusterAnnotationView was being returned instead of the custom cluster annotation view class provided which is a bug. The reason being you'll never have access to the correct annotation when the cluster is split into individual annotations. TSClusterAnnotationView will always point to the wrapper cluster annotation and never the original annotation that you added to the mapView.

Also for any visual changes, you don't want to be making changes to TSClusterAnnotationView

Still looking into #8

ashare80 avatar Mar 10 '15 17:03 ashare80

Ok, please tell me when that bug is solved because I will need access to the custom annotationView to change the image sometimes to make them look as "selected" (the user can select them from a list of locations).

Now with the new code, all the annotations make a kind of blinking when they are "relocated" because of the change of the layout but at least they are not disappearing!

Thanks

zfrankz avatar Mar 11 '15 18:03 zfrankz

@zfrankz I'm assuming your map height change is animated? Recreated something like you describe with an animated change of the layout constraints to the mapView.

I believe there's a clashing of the UIView animation in the clustering and the animated layout of subviews during an animated change of the frame or constraints.

Working on a fix to the problem.

ashare80 avatar Mar 20 '15 17:03 ashare80

Yes, is animating the height of the map view. Thanks for the support.

zfrankz avatar Mar 30 '15 10:03 zfrankz

Changing the height of the map is very heavy for some devices so I decided to change map region offset instead.

zfrankz avatar May 26 '15 17:05 zfrankz

@zfrankz Nice that's probably the better way to do it.

Since annotations are treated as subviews they re-layout during frame changes which causes the problems with animations.

ashare80 avatar May 26 '15 17:05 ashare80