Mapping GISPs Again With Leaflet.markercluster

So I’ve been playing with Leaflet a lot lately. It’s become my lightweight mapping library of choice. There’s a lot it doesn’t do so I keep OpenLayers and others in the rotation as well but Leaflet is direct and to the point so I use it when I can.

Click the image to go to the live demo

A while back, I stumbled onto the Leaflet.markercluster project on GitHub, which adds a clustering layer type. I wanted to try it so I revisited my old GISP heat map demo (Silverlight) and decided to rework it. I was happy to finally get a chance to strip out the plug-in, anyway.

This time around, I chose not to bother with the PMP data because it was kind of a pain to process the last time. I downloaded the GISP data from the GISCI site and once again ran it through GeoCommons to geocode it. This time, there were noticeable anomalies, such as positional accuracy problems (Richmond, VA was 25 miles east of where it should have been) and surprising omissions such as a failure to match major cities like Jacksonville, Florida and Phoenix, Arizona. I corrected some of the more egregious problems by hand and dumped the rest. Luckily none of this got in the way of the real goal of testing the clustering library but, if you visit the live demo, any anomalies you may notice are most likely related to the data and not the library.

Once geocoding was complete, I downloaded the CSV and processed it into the JSON structure expected by the marker cluster library. The library is still fairly new, and I am fairly new to using it so I had some problems if I deviated from the sample format. As a result, I stuck to that format and resolved to investigate it more. After that, it was very easy to wire up into a light application, with the clusters thrown on top of some tiles from MapBox. (Thanks to Bill Morris for showing me that base map.)

I think I prefer this representation to a heat map as it conveys more information at a glance. I’m happy to have this library in my toolbox now and am looking forward to seeing it evolve. I recommend checking it out.

Advertisements
This entry was posted in gis, web development and tagged , , , , , . Bookmark the permalink.