Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling clusterisation #36

Open
karonator opened this issue May 23, 2014 · 11 comments
Open

Disabling clusterisation #36

karonator opened this issue May 23, 2014 · 11 comments

Comments

@karonator
Copy link

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.

@choefele
Copy link
Owner

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

@karonator
Copy link
Author

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
Copy link
Author

@choefele
Any ideas? =(

@choefele
Copy link
Owner

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.

@karonator
Copy link
Author

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?

@choefele
Copy link
Owner

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

@karonator
Copy link
Author

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.

@lexin
Copy link

lexin commented Mar 5, 2015

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
Copy link

lexin commented Mar 5, 2015

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

@mikrobi
Copy link

mikrobi commented Apr 9, 2015

@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

@lexin
Copy link

lexin commented Apr 9, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants