Leaflet.markercluster icon indicating copy to clipboard operation
Leaflet.markercluster copied to clipboard

Optional spiderfy sort function

Open jbccollins opened this issue 7 years ago • 2 comments

It would be awesome if order in which markers were displayed in the spiderfied spirals was able to be customized. My use case: I want to use single marker mode and have my markers be pie charts. I'd like to be able to sort the single marker nodes so that markers of the same color are all grouped together. screen shot 2018-05-09 at 6 11 50 pm

For example in this screenshot I'd like to be able to have a meaningful orderering to the colors displayed in the spiral.

jbccollins avatar May 09 '18 22:05 jbccollins

How did you get donut charts working? I've been struggling with this, and have been considering switching to a different plug-in

Neato-Nick avatar Aug 22 '18 21:08 Neato-Nick

@Neato-Nick I'm using react and as such react-leaflet and react-leaflet-markercluster. The pie chart is from react-svg-piechart so you could take a look at their implementation. I use the iconCreateFunction provided by leaflet-markercluster which returns a divIcon.

L.divIcon({
      html: ReactDOMServer.renderToStaticMarkup(
        <div>
          <span
            style={{color: childCount === 1 ? 'white' : ''}}
            className={`cluster-count${childCount === 1 ? ' single' : ''}`}>
              {totalCount}
          </span>
          <PieChart data={data}/>
        </div>
      ),
      className: `pie-cluster`, 
      iconSize: new L.Point(size, size)
    })

jbccollins avatar Aug 22 '18 21:08 jbccollins