chancezeus / oms

Typescript fork of https://github.com/jawj/OverlappingMarkerSpiderfier
10 stars 11 forks source link

Sorting spiral #7

Open sie9 opened 2 years ago

sie9 commented 2 years ago

Hi,

How could i sort the order of the spiral?

i have a device with an id and i would like that the spiral is sorted by this id.

I have read that somewhere you sort by position, by i have tried to change the position before to add it but that's not working.

Thanks!

chancezeus commented 2 years ago

There is no sorting support, both variants (spiral/circle) work by finding the marker closest to the circle/spiral point (see https://github.com/chancezeus/oms/blob/master/lib/oms.ts#L318) so if you really want sorting then you'd have to lay out the markers the same way the circle/spiral is generated (see https://github.com/chancezeus/oms/blob/f266686717874310f76c3a6179e05aaa28acae5f/lib/oms.ts#L160 and https://github.com/chancezeus/oms/blob/f266686717874310f76c3a6179e05aaa28acae5f/lib/oms.ts#L146).

sie9 commented 2 years ago

yes i have tryed to formatting the position before addMarker but it makes a different spiral and i couldnt make it. I have copy that method and getting the array of positions and giving the position sorted to the markers but makes a bigger spiral.