[GIS] Possible to show aggregate votes in a tooltip on a markercluster

leafletmapbox

I'm building an interface that would take poll data in and show some results over a marker cluster using Mapbox but I don't have any experience with it.

The interface would look much like https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-markercluster/

If you click on the cluster instead of zooming in a tooltip would show up with a breakdown of (yes/no) votes in a pie chart like this https://www.dropbox.com/s/hv4c8708wlhe4mt/Screenshot%202014-11-30%2015.27.53.png?dl=0

In the GeoJSON data I was thinking each data point would have a property to state the vote value and somehow I could look at them in aggregate at the cluster level

geoJSON structure

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "vote": "yes" //no
  }
}

Is this possible using these libraries and geoJSON data structure? Am I on the right track?

Best Answer

The Leaflet markers clusterer can be used to show directly pie charts on the map. An example is visible on this map showing the breakdown of accidents in Oslo. The code behind is rather well explained and could be adapted for your case.