Leaflet (software) explained

Leaflet
Author:Volodymyr Agafonkin
Programming Language:JavaScript
Platform:See Browser support
Genre:JavaScript library
License:BSD-2-Clause[1]

Leaflet is a JavaScript library used to build web mapping applications. It allows developers without a GIS background 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,[2] 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 Volodymyr Agafonkin, who joined Mapbox in 2013.[3]

Leaflet is an open-source, JavaScript-based library for creating interactive maps. It was created in 2011 by Volodymyr Agafonkin, a Ukrainian citizen.[4] It covers a wide range of features a developer would need in creating interactive maps. It is supported by many browsers such as Chrome, Firefox, Safari 5+, Opera 12+, Internet Explorer 9 or later versions, and Edge.[5] It supports many third-party plugins, thus enabling the developer to integrate different kinds of features, such as Tile and image layering, Overlay displays, and various interactions into the map; these plugins help the developer create excellent maps. [6]

Being a lightweight (about 42KB of JS) [7] as intended, Leaflet enjoys a fantastic community of contributors helping to maintain it. It is built with simplicity; one good thing about Leaflet is its readable, easy-to-follow source code with rich API documentation. The Leaflet is still new; more effort could focused on providing detailed source code examples, such as step-by-step guidance for implementing third-party plugins. Most of its resources are docked in GitHub and can easily be downloaded and modified however you wish, and the source codes are entirely open source.[8]

So far, three versions of Leaflet have been released, with its most stable version (Leaflet 1.9.4) released on May 18, 2023. The previous version (Leaflet 1.8.0) was released on April 18, 2022. A new version (Leaflet 2.0) is being developed, and its release date is yet to be set. [9]

Use

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.

Leaflet Map Example

In this code sample, the Leaflet library itself is accessible through the variable L.

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:[10]

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

Support for GIS formats

Leaflet has core support for multiple GIS standard formats, with others supported in plugins.

Standard Support
Good, core support through the geoJson function[11]
KML, CSV, WKT, TopoJSON, GPX Supported in Leaflet-Omnivore plugin[12]
Core support through the TileLayer.WMS[13] subtype
Not supported, although third-party plugins exist.[14]
Not supported.[15]

Browser support

Leaflet 0.7 supports Chrome, Firefox, Safari 5+, Opera 12+ and IE 7–11.[16]

Examples of useful features

Leaflet's onEachFeature is quite handy when dealing with, for example, geojson data. The function contains two parameters: "feature" and "layer". "feature" allows us to access each object inside the geojson and "layer" allows us to add popups, tooltips etc.

An example in javascript is given below:

let geoJson = L.geoJSON(geoJsonData,).addTo(map); const getFeature= (feature, layer) =>

Notes and References

  1. Web site: License - Leaflet . 2018-11-03 . Leaflet.
  2. Web site: Testing web map APIs - Google vs OpenLayers vs Leaflet . dead . https://web.archive.org/web/20171103225922/http://robinlovelace.net/software/2014/03/05/webmap-test.html . 2017-11-03 . Lovelace . Robin . 2018-11-03.
  3. Web site: Leaflet Creator Vladimir Agafonkin Joins MapBox . 2014-08-06 . 2018-11-03 . MacWright. Tom.
  4. Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps. https://leafletjs.com/index.html
  5. Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps. https://leafletjs.com/index.html
  6. Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps. https://leafletjs.com/index.html
  7. Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps. https://leafletjs.com/index.html
  8. Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps. https://leafletjs.com/index.html
  9. Web site: Leaflet Creator Vladimir Agafonkin Joins MapBox . 2014-08-06 . 2018-11-03 . MacWright. Tom.
  10. Web site: Leaflet API reference . 2018-11-03.
  11. Web site: Using GeoJSON with Leaflet . 2018-11-03.
  12. Web site: leaflet-omnivore. October 5, 2021. GitHub.
  13. Web site: TileLayer.WMS . 2018-11-03.
  14. Web site: Leaflet with WFS Example. July 19, 2019. GitHub.
  15. Web site: Support for GML . . 2018-11-03 . 2012-06-23.
  16. Web site: Features . 2018-11-03.