WhirlyGlobe
WhirlyGlobe copied to clipboard
Remove and update individual markers
I have a fairly large set of markers. It would be helpful if I could update a single marker like to change the image, hide it, or remove it all together.
I do this sort of thing too. There are some tricks to maintaining large batches of markers, but being able to modify individual ones.
The biggest trick is to run them through the layout engine, if you're not already. So the first question is, what are you setting layoutImportance to? And are you using version 2.4 (develop branch)?
I'm using Max_Float and I'm on the 2.4.8 beta
2.4.1 you mean? Or are you from The Future. If so, what else did I put in 2.4.8?
MAXFLOAT will bypass the layout engine. One trick you could try is to set the layoutImportance to 1 (or something) and then set the layoutSize to (0,0). That will pass markers through the layout engine, but not force them to be laid out. So they'll be as optimized as possible, but still addressable individually.
There will be a little delay as you change markers (or add/remove them). If you need real-time responses, that gets harder.
I meant what ever branch is v2.4_beta8 is on. I need them to be in real-time, I'm turning them off an on as the user moves their finger across the globe.
That's more difficult. How many markers are there and how many might you be changing at once?
It really depends, there are maybe 100-300 and I need to turn them off as they leave the search range, so potently 25% or so.
Tricky. I can't think of a use case exactly like that, so I'd probably try one or two things before I settled.
The layout engine probably can't help here. Be sure to create your MaplyTexture objects ahead of time, rather than letting the toolkit do it each time. I'd create a dispatch queue and do the work there. Then you're not holding up the main thread. Then create all new markers, remove the old ones and wrap the whole thing in a beginChanges/endChanges.
So I have to remove all the markers then re-add the ones that don't change
There are other ways, but that's the simplest optimized way. The unoptimized way is to add each marker individually so you can remove them individually.
The problem is I have some other makers that are animated and I if remove then and re-add to change the image on a few of them animation restarts.
How about enable/disable? The problem, though, is you'll have to represent each marker individually, which may be slow.
So I think like a dynamic marker is need that can be hidden, and changed with out the removing it.
That would be interesting. You could have a set of fields you update individually or in groups.