thoughtbot / TBAnnotationClustering

Example App: How To Efficiently Display Large Amounts of Data on iOS Maps
http://robots.thoughtbot.com/how-to-handle-large-amounts-of-data-on-maps/
MIT License
728 stars 125 forks source link

Getting clustered annotation #2

Closed Janak-Nirmal closed 10 years ago

Janak-Nirmal commented 10 years ago

Hi,

Thank you for this control.

Is it possible to get all clustered annotation when we click on any annotation ? e.g. we can get count of the a clustered annotation but which places where covered under that clustered pin is what I am looking for, was not able to find it so just a quick question.

Thanks,

theocalmes commented 10 years ago

Yes.

under - (NSArray *)clusteredAnnotationsWithinMapRect:(MKMapRect)rect withZoomScale:(double)zoomScale

TBQuadTreeGatherDataInRange(self.root, TBBoundingBoxForMapRect(mapRect), ^(TBQuadTreeNodeData data) {
                totalX += data.x;
                totalY += data.y;
                count++;

                TBHotelInfo hotelInfo = *(TBHotelInfo *)data.data;
                [names addObject:[NSString stringWithFormat:@"%s", hotelInfo.hotelName]];
                [phoneNumbers addObject:[NSString stringWithFormat:@"%s", hotelInfo.hotelPhoneNumber]];
            });

gives you everything within a cluster. You could modify this function to keep refs to all the data in your annotation.