TSClusterMapView
TSClusterMapView copied to clipboard
Is there a way to intercept the click to does not expand the pins in the last zoom level?
Hii, First, thank you for sharing this great and useful lib. I am trying to use it, but I want a little different behavior when I give zoom in the last level and is not be possible to ungroup the pins. In this scenario, I want to intercept the default behavior (replace the pins around the original coordinate when the user tap on pin). In my case I wish to display some list with the places data (because I need to show all shops (200+) in the mall, for example). But I was not be able to disable this default behavior and insert my code.
If there is a way, I appreciate it if you could help me. Thank you very much! Best regards,
Paulo Santana.
Hi, I found out! Just return "false" in:
-
(BOOL)mapView:(TSClusterMapView *)mapView shouldForceSplitClusterAnnotation:(ADClusterAnnotation *)clusterAnnotation;
Thank you!!
Hi,
If possible I would to suggest a little modification. If there are a lot of places very close to each other, with another places with exactly the same coordinates, the algorithm not call the method below:
-(BOOL)mapView:(TSClusterMapView *)mapView shouldForceSplitClusterAnnotation:(ADClusterAnnotation *)clusterAnnotation;
Debugging the code, I find out the reason. Because the method is only called when the groupedRounded annotations count is equal to 1:
//...TSClusterMapView class, in "splitClusterToOriginal:clusterAnnotation" method
NSDictionary *groupedRoundedLatLonAnnotations = [TSClusterOperation groupAnnotationsByLocationValue:[NSSet setWithArray:clusterAnnotation.cluster.originalAnnotations]];
//Here the condition
if (groupedRoundedLatLonAnnotations.allKeys.count == 1) {
if ([_clusterDelegate respondsToSelector:@selector(mapView:shouldForceSplitClusterAnnotation:)]) {
if (![_clusterDelegate mapView:self shouldForceSplitClusterAnnotation:clusterAnnotation]) {
return;
}
}
}
Maybe this condition can be parameterized (count value). In my case, for example, I don't need this condition. Please correct me if I am wrong.
Thank you very much!
@pcsantana Hmm yeah I guess the idea there was that if they weren't close enough to get grouped together into 1 single shared coordinate it should always split.
I think we can just get rid of that if statement of that solves your problem?
Yes @ashare80, I commented the if statement and it solved my problem
@pcsantana ok cool next version will remove it
Thank you! :)