What is leaflet.js?

Leaflet.js is an Open Source JavaScript library that makes deploying maps on a web page easy. Being Open Source means that the code can be easily viewed to see how it works, anyone can use it and more importantly anyone can contribute back to the project with improvements to the code.

To provide all this mapping goodness it uses a paltry 34kB (at time of writing) JavaScript file that loads with your web page and provides access to a range of functions that will allow you to present a map. There is support for modern browsers in desktop and mobile platforms so you can deploy your map pretty much anywhere.

Its goals are to be simple to use while focussing on performance and usability, but it’s also built to be extended using plugins that extend its functionality. It has an excellent API which is well documented, so there are no mysteries to using it successfully in a range of situations. Companies who are already touted as using Leaflet include Flickr, foursquare, craigslist, Data.gov, IGN, Wikimedia, OSM, Meetup, WSJ, MapBox, CloudMade, CartoDB and GIS Cloud. Now I’m picking that you’ll agree that that’s a list of significant players on the Internet. However, with Leaflet, you can make and deploy maps in much that same way that these organisations do.

Out of the box Leaflet provides the functionality to add markers, popups, overlay lines and shapes, use multiple layers, zoom, pan and generally have a good time :-). But these are just the the core features of Leaflet. One of the significant strengths of Leaflet is the ability to extend the functionality of the script with plugins from third parties. At the time of writing there are over 80 separate plugins that allow features such as overlaying a heatmap, animating markers, loading csv files of data, drawing complex shapes, measuring distance, manipulating layers and displaying coordinates.

Leaflet is truly a jewel of Open Source software. Simple, elegant, functional but powerful. There’s a good chance that even if you don’t present maps with Leaflet, you’ll be using ones that someone else made with it at some stage on the Internet.