Leaflet (software)

From Infogalactic: the planetary knowledge core
Jump to: navigation, search
Leaflet
Original author(s) Vladimir Agafonkin
Initial release May 13, 2011 (2011-05-13)
Stable release 0.7.7 (October 26, 2015 (2015-10-26))
Development status Active
Written in JavaScript
Platform See Browser support
Type JavaScript library
License BSD-2-Clause[1]
Website leafletjs.com

Leaflet is a widely used open source JavaScript library used to build web mapping applications. First released in 2011,[2] it supports most mobile and desktop platforms, supporting HTML5 and CSS3. Along with OpenLayers, and the Google Maps API, it is one of the most popular JavaScript mapping libraries and is used by major web sites such as FourSquare, Pinterest and Flickr.

Leaflet allows developers without a GIS background to very easily 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.

It is developed by Vladimir Agafonkin, who joined MapBox in 2013.[3]

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.

 // create a map in the "map" div, set the view to a given place and zoom
 var map = L.map('map').setView([51.505, -0.09], 13);
 
 // add an OpenStreetMap tile layer
 L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
     attribution: '&amp;copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
 }).addTo(map);

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

  • 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 are 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 few GIS standard formats, with others supported in plugins.

Standard Support
GeoJSON Good, core support through the geoJson function[5]
KML, CSV, WKT, TopoJSON, GPX Supported in Leaflet-Omnivore plugin[6]
WMS Core support through the TileLayer.WMS[7] subtype
WFS Not supported, although 3rd party plugins exist.[8]
GML Not supported.[9]

Browser support

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

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 230,000 as of 2015.[11] It has a smaller code footprint than OpenLayers (around 123 KB[12] vs 423 KB[13]) 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)[14] and native support for projections other than Google Web Mercator (EPSG 3857).[15]

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 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.[16]

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.[17]

  • 0.1: May 17, 2011
  • 0.2: June 18, 2011
  • 0.3: Feb 14, 2012
  • 0.4: Jul 30, 2012
  • 0.5: Jan 17, 2013

This release introduced Retina support and many usability and user experience improvements.[18]

  • 0.6: Jun 26, 2013

This release expanded the API's range of methods and events, improved usability, and added GeoJSON saving. It was completed in a 2-day code sprint supported by Mapbox.[19]

  • 0.7: Nov 22, 2013

This release focused on bug fixing, announcing that refactoring and potential backward incompatibilities would come soon.[20]

External links

References

  1. Lua error in package.lua at line 80: module 'strict' not found.
  2. Lua error in package.lua at line 80: module 'strict' not found.
  3. Lua error in package.lua at line 80: module 'strict' not found.
  4. Lua error in package.lua at line 80: module 'strict' not found.
  5. http://leafletjs.com/examples/geojson.html
  6. https://github.com/mapbox/leaflet-omnivore
  7. Lua error in package.lua at line 80: module 'strict' not found.
  8. https://github.com/Georepublic/leaflet-wfs
  9. https://github.com/Leaflet/Leaflet/issues/547
  10. Lua error in package.lua at line 80: module 'strict' not found.
  11. Lua error in package.lua at line 80: module 'strict' not found.
  12. Lua error in package.lua at line 80: module 'strict' not found.
  13. Lua error in package.lua at line 80: module 'strict' not found.
  14. Various plugins providing WFS-support are listed on http://leafletjs.com/plugins.html
  15. http://leafletjs.com/reference.html#IProjection
  16. https://developers.google.com/maps/documentation/javascript/datalayer
  17. Lua error in package.lua at line 80: module 'strict' not found.
  18. Lua error in package.lua at line 80: module 'strict' not found.
  19. Lua error in package.lua at line 80: module 'strict' not found.
  20. Lua error in package.lua at line 80: module 'strict' not found.