Leaflet (software)

Leaflet
Original authorVolodymyr Agafonkin
ReleaseMay 13, 2011 (2011-05-13)
Stable release
1.9.4Edit this on Wikidata / 18 May 2023; 3 years ago (18 May 2023)
Written inJavaScript
PlatformSee Browser support
TypeJavaScript library
LicenseBSD-2-Clause
Websiteleafletjs.com
Repository

Leaflet is a JavaScript library used to build web mapping applications. It allows developers to display tiled web maps hosted on a public server, with optional tiled overlays. It can load feature data from GeoJSON files, style it and create interactive layers, such as markers with popups when clicked.

First released in 2011, it supports most mobile and desktop platforms, supporting HTML5 and CSS3. Among its users are FourSquare, Pinterest, Flickr, and the USGS.

Leaflet is open source, and is developed by Ukrainian developer Volodymyr Agafonkin, who joined Mapbox in 2013. After the invasion of Ukraine by Russia in 2022, a version of logo was created to reflect the colours of Ukraine, which is used on a pop-up the first page of the website, promoting support for Ukraine.

Use

A basic demo using Leaflet.

A typical use of Leaflet involves binding a Leaflet "map" element to an HTML element such as a div. Layers and markers are then added to the map element.

Features

Leaflet supports Web Map Service (WMS) layers, GeoJSON layers, Vector layers and Tile layers natively. Many other types of layers are supported via plugins.

Like other web map libraries, the basic display model implemented by Leaflet is one basemap, plus zero or more translucent overlays, with zero or more vector objects displayed on top.

Elements

The major Leaflet object types are:

  • Raster types (TileLayer and ImageOverlay)
  • Vector types (Path, Polygon, and specific types such as Circle)
  • Grouped types (LayerGroup, FeatureGroup and GeoJSON)
  • Controls (Zoom, Layers, etc.)

There is also a variety of utility classes such as interfaces for managing projections, transformations and interacting with the Document Object Model (DOM).

Support for GIS formats

Leaflet has core support for multiple geographic information system (GIS) standard formats, with others supported in plugins.

StandardSupport
GeoJSONGood, core support through the geoJson function
KML, CSV, WKT, TopoJSON, GPXSupported in Leaflet-Omnivore plugin
TMS Core support through TileLayer
WMSCore support through the TileLayer.WMS subtype
WFSNot supported, although third-party plugins exist.
GMLNot supported.

Browser support

Leaflet 1.9 supports Chrome, Firefox, Safari 5+, Opera 12+, IE 9–11 and Edge.

Leaflet 0.7 supported Chrome, Firefox, Safari 5+, Opera 12+ and IE 7–11.

Comparison with other libraries

Leaflet is directly comparable with OpenLayers, as both are open source, client-side only JavaScript libraries. The library as a whole is much smaller, around 7,000 lines of code compared to OpenLayers' 230,000 (as of 2015). It has a smaller code footprint than OpenLayers (around 123 KB vs 423 KB) due partly to its modular structure. The code base is newer, and takes advantage of recent features of JavaScript, plus HTML5 and CSS3. However, Leaflet lacks features OpenLayers supports, such as Web Feature Service (WFS) and native support for projections other than Google Web Mercator (EPSG 3857).

It is also comparable to the proprietary, closed source Google Maps API (debuting in 2005) and Bing Maps API, both of which incorporate a significant server-side component to provide services such as geocoding, routing, search and integration with features such as Google Earth.[citation needed] Google Maps API provides speed and simplicity, but is not flexible, and can only be used to access Google Maps services. The new DataLayer part of Google's API does allow external data sources to be displayed, however.

History

Leaflet began life in 2010 as "Web Maps API", a JavaScript library for the CloudMade mapping provider, where Agafonkin worked at the time. In May 2011, CloudMade announced the first release of Leaflet, built from scratch but using parts of the old API code.

In March 2022, the developer urged action on the Russian invasion of Ukraine on the Leaflet website.