google-maps-ios-utils icon indicating copy to clipboard operation
google-maps-ios-utils copied to clipboard

Update cluster Items after adding

Open chlebta opened this issue 10 years ago • 13 comments

How to updated cluster Items after adding them without need for removing then re-adding them ?

chlebta avatar Aug 02 '16 11:08 chlebta

I assume that you were referring to updating cluster item's position? If it is the case then you can call [clusterManager cluster] again after your update(s). Remember that for good performance, perform all your updates and call [clusterManager cluster] at the end.

mountainvat avatar Aug 03 '16 00:08 mountainvat

But _items array is not accessible from outside so I can update the data

chlebta avatar Aug 03 '16 08:08 chlebta

I'd imagine you could hold on to the items in a separate array when you add them to the clusterManager.

mountainvat avatar Aug 04 '16 00:08 mountainvat

Items will passed by reference or value ?

chlebta avatar Aug 09 '16 16:08 chlebta

By reference so you only need to update them in your original list.

mountainvat avatar Aug 09 '16 23:08 mountainvat

@chlebta Have you got any luck? Can I close the ticket?

mountainvat avatar Aug 23 '16 23:08 mountainvat

@mountainvat a question related to this. Imagine that we have a huge database and all the items will be markers on the map. Do we need to download all the information we need first and only after that update the cluster manager? This can cause a long delay before anything is being showed to the user. Do you know if there is any other way to handle this without losing performance? E.g. updating the cluster manager every time a marker is added.

amadeubandrade avatar Oct 05 '16 09:10 amadeubandrade

Is the database on the mobile or on a server? If it is on a server, it is probably best to do some server side filtering. So you'd give the server your latitude ,longitude range of interest and the server will only return items within that range for example. Downloading all items to the client is not very scalable.

mountainvat avatar Oct 05 '16 21:10 mountainvat

Closing this issue out as stale. Please re-open if this is still an issue. Thanks!

domesticmouse avatar May 31 '17 04:05 domesticmouse

Hi, I have an array of cluster item and i am updating the position of particular cluster item, but the app is getting crashed. All i want a way is to update position of particular cluster item.

I am doing something like this: item.position = Some coordinate clusterManager?.cluster()

Following is the error i got when i updated the position. Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'All items should be mapped to a distance'

Can some please tell me how to do it. Really appreciate quick response because i am stuck into this.

ravigupta049 avatar Jul 27 '18 10:07 ravigupta049

the same issues.

lexuanquynh avatar Aug 04 '18 10:08 lexuanquynh

check lat: if lat > 85 || lat < -85 { //don't add clusterManager.add(item) } it a little code make app not crash, but I don't know why it run.

lexuanquynh avatar Aug 04 '18 11:08 lexuanquynh

I ran into this issue too and it was due to using invalid lat long values.

kwilk83 avatar Dec 19 '18 01:12 kwilk83