Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Leaflet (software)

From Wikipedia, the free encyclopedia
JavaScript library for web mapping applications
Leaflet
Original author(s)Volodymyr Agafonkin
Initial releaseMay 13, 2011 (2011-05-13)
Stable release
1.9.4[1]Edit this on Wikidata / 18 May 2023; 23 months ago (18 May 2023)
Repository
Written inJavaScript
PlatformSeeBrowser support
TypeJavaScript library
LicenseBSD-2-Clause[2]
Websiteleafletjs.com

Leaflet is aJavaScriptlibrary used to buildweb mappingapplications. It allows developers without a GIS background to displaytiled web maps hosted on a public server, with optional tiled overlays. It can load feature data fromGeoJSON files, style it and create interactive layers, such as markers with popups when clicked.

First released in 2011,[3] it supports most mobile and desktop platforms, supportingHTML5 andCSS3. Among its users areFourSquare,Pinterest,Flickr, and theUSGS.

Leaflet isopen source, and is developed by Volodymyr Agafonkin, who joinedMapbox in 2013.[4]

Leaflet is an open-source, JavaScript-based library for creating interactive maps. It was created in 2011 by Volodymyr Agafonkin, a Ukrainian citizen.[5] 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.[6] 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.[7]

Being a lightweight (about 42 KB of JS)[8] 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.[9]

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

Use

[edit]
A basic demo using Leaflet.

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

<html><head><title>Leaflet Map Example</title><!-- Link to Leaflet CSS file --><linkrel="stylesheet"href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"/><!-- Link to Leaflet JavaScript file --><scriptsrc="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script><style>#map{height:250px;width:400px;border:1pxsolidgray;}</style></head><body><divid="map"></div><script>// Initialize the mapvarmap=L.map('map').setView([51.505,-0.09],13);// Add the tile layer (you can choose a different map style by changing the URL)L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);// Add a circle overlay with a specific radius and colorvarcircle=L.circle([51.508,-0.11],{color:'red',radius:500// Radius in meters}).addTo(map);// Add a marker with a popupvarmarker=L.marker([51.5,-0.09]).addTo(map).bindPopup('<b>Hello World!</b><br/> I am a popup.');</script></body></html>

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

Features

[edit]

Leaflet supportsWeb Map Service (WMS) layers,GeoJSON layers,Vector layers and Tile layers natively. Many other types of layers are supported viaplugins.

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

[edit]

The major Leaflet object types are:[11]

  • 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 theDOM.

Support for GIS formats

[edit]

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

StandardSupport
GeoJSONGood, core support through thegeoJson function[12]
KML, CSV, WKT, TopoJSON, GPXSupported in Leaflet-Omnivore plugin[13]
WMSCore support through theTileLayer.WMS[14] subtype
WFSNot supported, although third-party plugins exist.[15]
GMLNot supported.[16]

Browser support

[edit]

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

Examples of useful features

[edit]
Theneutrality of this article isdisputed. Relevant discussion may be found on thetalk page. Please do not remove this message untilconditions to do so are met.(September 2024) (Learn how and when to remove this message)

Leaflet'sonEachFeature 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:

letgeoJson=L.geoJSON(geoJsonData,{weight:2,onEachFeature:getFeature,style:getStyle}).addTo(map);constgetFeature=(feature,layer)=>{if(!feature.properties.name)returnlayer.bindTooltip(feature.properties.cityName);layer.bindPopup(`<ul>            <li>Name:${feature.properties.cityName}</li>            <li>Population:${feature.properties.population}</li>        </ul>`)};

It is also possible to add "async" keyword togetFeature function in order to use promises such asfetch(). We can utilise properties in each object of GeoJSON to create customised jsonqueries and get, for example, city-specific information and display them usinglayer.bindTooltip,layer.bindPopup, etc.

Comparison with other libraries

[edit]

Leaflet is directly comparable withOpenLayers, 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).[18] It has a smaller code footprint than OpenLayers (around 123 KB[19] vs 423 KB[20]) 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 asWeb Feature Service (WFS)[21] and native support for projections other than GoogleWeb Mercator (EPSG 3857).[22]

It is also comparable to the proprietary, closed sourceGoogle Maps API (debuting in 2005) andBing Maps API, both of which incorporate a significant server-side component to provide services such asgeocoding,routing, search and integration with features such as GoogleEarth.[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.[23]

History

[edit]

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

  • 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 introducedRetina support and many usability and user experience improvements.[25]
  • 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.[26]
  • 0.7: Nov 22, 2013
    • This release focused on bug fixing, announcing that refactoring and potential backward incompatibilities would come soon.[27]
  • 1.0: Sep 27, 2016
    • This release contained over 400 changes compared to v0.7.7:[28]
      • Performance improvements in all aspects of the library and vector layers in particular.
      • Flyover animations (zooming and panning in a curve).
      • Fractional zoom level support.
      • Better tile loading algorithm with less flickering.
      • Custom pane management (including multiple vector layer panes and interleaving vectors and tile layers).
      • Better support for non-standard projections.
      • More accessibility features.
      • Improved documentation.
      • Stability improvements.
  • 1.1: Jun 27, 2017
    • This release adds video overlays and makes a transition to ECMAScript 6 modules.
  • 1.2: Oct 25, 2017
  • 1.3: Jan 15, 2018
  • 1.3.2: Jul 17, 2018
  • 1.3.3: Jul 18, 2018
  • 1.3.4: Aug 21, 2018
  • 1.4.0: Dec 30, 2018
  • 1.5.0 and 1.5.1: May 8, 2019
  • 1.6.0: Nov 17, 2019
  • 1.7.1: September 4, 2020
  • 1.8: April 18, 2022[29]
  • 1.9: September 22, 2022[30]

In March 2022, the developer urged action on theRussian invasion of Ukraine on the Leaflet website.[31]

References

[edit]
  1. ^"v1.9.4 Latest". 18 May 2023. Retrieved20 May 2023.
  2. ^"License - Leaflet". Leaflet. Retrieved2018-11-03.
  3. ^Lovelace, Robin."Testing web map APIs - Google vs OpenLayers vs Leaflet". Archived fromthe original on 2017-11-03. Retrieved2018-11-03.
  4. ^MacWright, Tom (2014-08-06)."Leaflet Creator Vladimir Agafonkin Joins MapBox". Retrieved2018-11-03.
  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. ^Agafonkin, V. (2024, July 28). An open-source JavaScript library for mobile-friendly interactive maps.https://leafletjs.com/index.html
  10. ^MacWright, Tom (2014-08-06)."Leaflet Creator Vladimir Agafonkin Joins MapBox". Retrieved2018-11-03.
  11. ^"Leaflet API reference". Retrieved2018-11-03.
  12. ^"Using GeoJSON with Leaflet". Retrieved2018-11-03.
  13. ^"leaflet-omnivore". October 5, 2021 – via GitHub.
  14. ^"TileLayer.WMS". Retrieved2018-11-03.
  15. ^"Leaflet with WFS Example". July 19, 2019 – via GitHub.
  16. ^"Support for GML".GitHub. 2012-06-23. Retrieved2018-11-03.
  17. ^"Features". Retrieved2018-11-03.
  18. ^"OpenHub.net comparison between OpenLayers and Leaflet".OpenHub.net. Archived fromthe original on 2014-08-08. Retrieved2018-11-03.
  19. ^"Leaflet frontpage".Leaflet - An Open-Source JavaScript Library for Mobile-Friendly Interactive Maps. Retrieved2018-11-03.
  20. ^"OpenLayers 3.4.0 compressed source code". OpenLayers.org. Archived fromthe original on 2016-11-29. Retrieved2018-11-03.
  21. ^Various plugins providing WFS-support are listed onhttps://leafletjs.com/plugins.html
  22. ^"Projection". Retrieved2018-11-03.
  23. ^"Data Layer".Google Maps Platform. Google Inc. Retrieved2018-11-03.
  24. ^"Announcing Leaflet: a Modern Open Source JavaScript Library for Interactive Maps".CloudMade. 2011-05-13. Archived fromthe original on 2014-08-11. Retrieved2018-11-03.
  25. ^Agafonkin, Vladimir (2013-01-17)."Leaflet 0.5 Released". Retrieved2018-11-03.
  26. ^Agafonkin, Vladimir (2013-06-26)."Leaflet 0.6 Released, Code Sprint in DC with MapBox". Retrieved2018-11-03.
  27. ^Agafonkin, Vladimir (2013-11-18)."Leaflet 0.7 Release, MapBox and Plans for Future". Retrieved2018-11-03.
  28. ^Agafonkin, Vladimir (2016-09-27)."Meet Leaflet 1.0". Retrieved2018-11-03.
  29. ^Leaflet 1.8 released in the middle of war
  30. ^v1.9.0
  31. ^"Leaflet - a JavaScript library for interactive maps". 2022-03-21. Archived fromthe original on 21 March 2022. Retrieved2022-03-22.

External links

[edit]
Organisations
Software
Editing
Visualisation
Navigation
Derivations
People
Retrieved from "https://en.wikipedia.org/w/index.php?title=Leaflet_(software)&oldid=1286207159"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp