-
Notifications
You must be signed in to change notification settings - Fork 86
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
Use one single clusterManager for multiple view controllers and proposes #22
Comments
I think that a possible solution could be to initialize a QuadTree object that can be used as datasource for the mapView and that can provide, in another viewcontroller, the annotations near to the user location. |
Hi @jacogasp We need to balance the pros and cons of setting a tree to the cluster manager instead of an array of annotations.
#import <ClusterKit/CKQuadTree.h> import ClusterKit.CKQuadTree |
I changed the target membership of - (void)setQuadTree:(id<CKAnnotationTree>)quadTree {
_tree = quadTree;
_tree.delegate = self;
[self updateClusters];
} Then I can simply create a general purpose quadTree object as var quadTree = CKQuadTree()
quadTree = CKQuadTree(annotations: annotationsArray) and set the clusterManager of the mapView as let algorithm = CKNonHierarchicalDistanceBasedAlgorithm()
algorithm.cellSize = 300
mapView.clusterManager.algorithm = algorithm
mapView.clusterManager.marginFactor = 1
mapView.clusterManager.setQuadTree(quadTree) At this point it is possible to get the annotations within a certain let annotationsInRect = quadTree.annotations(in: rect) I think it's a very convenient way to access very quickly to the annotations stored into the quadTree object and reuse them for other purposes, preserving the benefits of the quadTree algorithm. |
I have a huge amount of POIs that I can successfully show over on the map. But I also need to search all the POIs within a certain distance from the user location, in a different view.
Is it possible to create one general cluster of annotations, accessing it from different view controllers and perform a search based on the user location?
The text was updated successfully, but these errors were encountered: