mobile-sdk
mobile-sdk copied to clipboard
[FR] VectorElement: property to prevent clustering
It would be nice to have a VectorElement property to prevent them from being clustered.
The simplest use case is item selection.
If you manage an "item" (VectorElement) selection within you app, you expect the selected item never to be clustered as long as it is selected. If is clustered the user cant really see what item is actually selected.
I am willing to try and make a PR for this. Would it be a good way to go? (still need to put the dev env in action)
This seems more related to app logic, IMO. What about using separate layer for selected elements and simply removing the element from clustered layer? Note that by removing the element (or by ignoring it while clustering) can change the clusters quite a lot, so another option is to make a copy of the selected element and not remove it at all.
@mtehver i get it might change a lot especially the "layout" of clusters. Now about the creation of another layer or copying the marker, always possible. But it would make it a lot easier to work with just to have it handled in the cluster. It would also allow any kind of behavior for dynamic handling of item to be clustered or not.
Also it s dead easy to handle in ClusteredVectorLayer (simply make sure the non clustering items remain alone in their cluster) while it requires a lot more logic to handle outside of it.
That s something i did before with Google Maps.
Would you accept a PR?
@farfromrefug Yes, we accept PRs. Just to be sure, how would you extend the API?
@mtehver well i think:
- i would need to modify
createSingletonClusterhere - to know if a
VectorElementcould be clustered i would need to have a property insideVectorElement. Something likecanBeClusteredas aboolean
Would that be ok with you?
TBH, I would not add anything to VectorElement as this would couple the design between layer and elements. Perhaps it is possible to add the list to ClusteredElementLayer?
Also, I think it is more complicated than simply modifying createSingletonCluster. You can only 'ignore' element there.
@mtehver so your thinking about adding a list of non clusterable items to ClusteredElementLayer ? That s seems a little overkill. Still i understand you not wanting to add a property to VectorElement Will have to think about this
@farfromrefug There is a third option - use a specific VectorElement metadata element to signal if element should be clustered. I am not sure this is better or cleaner, though.
@mtehver bumping that feature request a little bit. I have a little bit of time and would like to create a PR for this. However i am a little bit lost in the cluster building process, can't find where to prevent the cluster (singleton for item) to be merged with others. Can you guide me a bit? Thinking about using metadata as you mentioned. Thanks