Closed mvorisis closed 7 years ago
You can achieve that very easily by calling replace on clustering manager with your new annotations.
clusteringManager.replace(annotations: annotations)
mapView.showAnnotations(annotations, animated: false)
Thanks for answering me so quick, I have some questions though, Where should I use this command, and should I have to replace it with clusteringManager.addannotations?
A replace is nothing more than a removeAll
followed by a addannotations
so you should replace it with addAnnotations
if your new data set doesn't include old annotations that you want to keep on screen. You should call these methods when your network request completes.
Hi happy new year, to explain you how my app works i'll give you an example, my app launches and gets 3 annotations then every time I scroll it will get 3 more at a time (I have a function that checks if the annotation exists) so what do I have to add now in my code ?
Ok finally I found out what I was doing wrong.
I had a function to find out if the annotation I was going to add was existed.
This is the for I was using : for existPin in annots as! Array<FBAnnotation>
with this line I was taking cluster annotations too so I converted it to this: for existPin in array
.
Every time I was inserting new annotations I used the line you told me clusteringManager.replace(annotations: annotations)
but because I'm working on xcode 7 I used this line (the same but for swift 2) clusteringManager.setAnnotations(array)
.
Thank you for your time.
PS I didn't use mapView.showAnnotations(annotations, animated: false)
Hi
My app every time the user scrolls the map gets lats,longs from my server and add new annotations to the map, so my question is can I use this library with dynamic annotations? I thought that I can somehow empty clusteringManager.
Thanks in advance.