CCHMapClusterController icon indicating copy to clipboard operation
CCHMapClusterController copied to clipboard

Disabling clusterisation

Open karonator opened this issue 11 years ago • 11 comments
trafficstars

Hello. First of all, thanks for nice framework, working for me like a charm.

I have a question. I am moving a camera manually (some animation), and when I moving it, framework trying to make clusterisation every frame (I think it;s because of setCamera calls). Is there any way to manually stop and then resume clusterisation?

It will be nice if I'll can stop clusterisation, make animation, and the restart it.

Thanks for your time, Karen.

karonator avatar May 23 '14 11:05 karonator

Hi Karen,

At the moment, it's not possible to disable the clustering.

How do you animate the camera? Could you give me a code example?

The clustering happens whenever mapView:regionDidChangeAnimated: is called. Maybe there's a way to animate the camera without this method being called multiple times.

-Claus

choefele avatar May 23 '14 14:05 choefele

Hi Claus, sure I can, here it is:

  • (void) pinch_func: (UIPinchGestureRecognizer*) sender { if ([sender state] == UIGestureRecognizerStateBegan) { mm = [map.camera copy]; alt_log = log (map.camera.altitude); self.mapClusterController = nil; }

    const double alt_log_max = log (alt_max); const double alt_log_min = log (alt_min);

    if ([sender velocity] > 0) alt_log -= [sender scale] / 50.0; else alt_log += [sender scale] / 40.0;

    if (alt_log > alt_log_max) { alt_log = alt_log_max; } if (alt_log < alt_log_min) { alt_log = alt_log_min; }

    alt = exp (alt_log); pitch = [self pitchFromAlt: alt];

    mm.altitude = alt; mm.pitch = pitch;

    camera_altitude = alt;

    [map setCamera: mm animated: NO]; }

karonator avatar May 23 '14 14:05 karonator

@choefele Any ideas? =(

karonator avatar May 25 '14 11:05 karonator

Hi Karen,

At the moment, the only way to disable clustering would be to deallocate the CCHMapClusterController instance. This will leave the current annotations on the map view untouched. Then, when you have finished with the gesture, you could create a new instance and re-add the annotations to the cluster controller.

I know it's a bit of a hack, but could you try if this works?

I could offer a property to disable clustering temporarily, but I'm not sure this is a good idea.

choefele avatar May 26 '14 09:05 choefele

Hi again, Claus =)

Well, you know, too user there is no matter, hack it or not. I will try your idea and then I'll response here about the result.

And by the way I really not sure that disabling clusterisation (I mean property) can be really good feature, but I think it is easy to add, so why not?

karonator avatar May 26 '14 09:05 karonator

I haven't heard back on this issue for a while. Did my suggestion work for you?

choefele avatar Jun 20 '14 21:06 choefele

Hey Claus. Well, your suggestion worked, but clusterisation working laggy while camera is moving.

I think that it will be very good improvement, if there will be the way to stop automatically clustering and use reclusterisation manually.

karonator avatar Jun 23 '14 07:06 karonator

Hello. I have the same problem too. I have 10 -30 points in one city. When user tap on point

  • (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view I call ... [self.mapView setRegion:region animated:YES]; ..

And after this clusterisation works. But every time with different values, because region is different a bit. And this looks not good - after each user's selection clusters are redrawing.

lexin avatar Mar 05 '15 15:03 lexin

but! When user just swipe map regionDidChangeAnimated works too, but clusters are the same!

lexin avatar Mar 05 '15 15:03 lexin

@lexin you might wanna checkout the code recipes. There is one to center the map around a specific annotation without changing the zoom level: https://github.com/choefele/CCHMapClusterController#centering-the-map-without-changing-the-zoom-level

mikrobi avatar Apr 09 '15 08:04 mikrobi

@mikrobi Yes, thank you. I've made it like that.

lexin avatar Apr 09 '15 09:04 lexin