mobile-sdk icon indicating copy to clipboard operation
mobile-sdk copied to clipboard

[FR] VectorElement: property to prevent clustering

Open farfromrefug opened this issue 8 years ago • 8 comments

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)

farfromrefug avatar Nov 09 '17 14:11 farfromrefug

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 avatar Nov 13 '17 08:11 mtehver

@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 avatar Nov 13 '17 09:11 farfromrefug

@farfromrefug Yes, we accept PRs. Just to be sure, how would you extend the API?

mtehver avatar Nov 14 '17 15:11 mtehver

@mtehver well i think:

  • i would need to modify createSingletonCluster here
  • to know if a VectorElement could be clustered i would need to have a property inside VectorElement. Something like canBeClustered as a boolean

Would that be ok with you?

farfromrefug avatar Nov 14 '17 16:11 farfromrefug

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 avatar Nov 16 '17 13:11 mtehver

@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 avatar Nov 17 '17 07:11 farfromrefug

@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 avatar Nov 17 '17 12:11 mtehver

@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

farfromrefug avatar Dec 10 '18 15:12 farfromrefug