CCHMapClusterController icon indicating copy to clipboard operation
CCHMapClusterController copied to clipboard

Strange behavior when zooming in and out

Open maxencehenneron opened this issue 8 years ago • 14 comments

Good afternoon, I'm currently building an app for my family and I'm concerned about a bug when zooming the map.

As you can see in this video: https://www.youtube.com/watch?v=vjbB0sEtHSQ, on the first second, I'm zooming the map and one photo - or annotation - is removed from the cluster and after zooming again, the photo is back into the cluster. We can see this happening as well when zooming out on second 13, the stack contains 18 pictures, and after zooming out, one picture is removed from the stack.

It makes it look like the clusters are completely random, is it something I missed?

Thank you, Maxence Henneron.

maxencehenneron avatar Oct 12 '16 04:10 maxencehenneron

Hi – did you implement both mapView:(MKMapView *)mapView viewForAnnotation: and mapClusterController:willReuseMapClusterAnnotation:? The former is called when the annotation view is created and the latter when the annotation view is reused. In both cases, you'll have to properly updated your annotation views.

Also, make sure you only add annotations to the cluster manager and never to the map view directly

choefele avatar Oct 12 '16 07:10 choefele

Yes, both of then are implemented. I also did this:

self.mapClusterController.cellSize = CGFloat(self.mapView.frame.width / 6)

To conform to "The actual cell size used for clustering will be adjusted so that the map's width is a multiple of the cell size. This avoids realignment of cells when panning across the 180th meridian."

This is also happening in the example, sometimes zooming on a stack makes the cluster bigger (it shouldn't, since we are zooming, we may except the stack to be smaller) and zooming out makes a cluster smaller, when notifications should be added. The grid shown when isDebugingEnabled = true also shows strange movements, it seems that the alignment is changing

maxencehenneron avatar Oct 12 '16 15:10 maxencehenneron

I made a new video about this issue: Please pay attention to the random grid movement, which sometimes sets different stacks:

https://www.youtube.com/watch?v=_3k_LN9C65M&feature=youtu.be

maxencehenneron avatar Oct 12 '16 15:10 maxencehenneron

Hmm – have you compared this to the demo project in this repo? Does the sample in this repo show the same problem? Maybe you need to provide a sample project that reproduces this issue so I can debug the problem

choefele avatar Oct 12 '16 15:10 choefele

Hello, I have the same problem and would like to have a solution for this issue as well.

alexsteinerde avatar Oct 12 '16 16:10 alexsteinerde

So I made an example project :

Please go to Ukraine and you should see two stacks of photos, zoom as much as possible on one of those stacks and slowly zoom out, you will see that the two photos are always clustered/unclustered. It is easier to see on a real device.

CCHMapClusterProblem.zip

Here's a video on how to reproduce : https://youtu.be/qo_9DAKU_KI

maxencehenneron avatar Oct 12 '16 17:10 maxencehenneron

I can also reproduce the problem with the example that comes with the repo. This is a new problem – it looks like iOS 10 changed something so that the rect alignment used for the cluster cells doesn't work any more.

@dernise, @alexsteinerde can you have a look for a possible solution? I won#t be able to work on this for the next week or two

choefele avatar Oct 14 '16 15:10 choefele

Is there any news on this?

Preen avatar May 04 '17 14:05 Preen

Sorry, but I don't have time at the moment to look into this. Do you have an idea how to fix this?

Thanks

choefele avatar May 05 '17 10:05 choefele

Any news on this?

tobias-r avatar Aug 31 '17 17:08 tobias-r

Sorry, we ended up moving to another clustering solution, so I didn’t revisit the potential fix. I would still recommend doing what I outlined to avoid loading up multiple subviews that will never appear again.

On Aug 31, 2017, at 1:34 PM, tobias-r [email protected] wrote:

Any news on this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/choefele/CCHMapClusterController/issues/133#issuecomment-326368104, or mute the thread https://github.com/notifications/unsubscribe-auth/AAgy3KqW1Wx-7QIbmMY9ttHe47acjxb7ks5sdu7BgaJpZM4KUWam.

BenSS avatar Sep 06 '17 15:09 BenSS

@BenSS If I may ask, which maintained solution did you use instead?

mxcl avatar Mar 19 '18 18:03 mxcl

Same problem here, tried the Apple Solution from iOS 11 but it's terribly slow with a lot of markers. I believe it works with graphical collision and needs to render all the markers before clustering, so your solution is 1000 times better. Any chance you could improve this?

@BenSS Which solution did you use?

tobias-r avatar Jun 19 '18 14:06 tobias-r

@tobias-r The original fix/PR I didn't really have time to clean up was make sure the added views were removed. At the time they were left hanging around, so you could end up with hundreds stacked on top of each other.

We moved to Kingpin for iOS10, and using the built-in MapKit clustering for iOS 11+.

BenSS avatar Jun 19 '18 14:06 BenSS