2014-04-22 21:51:21 +08:00
---
layout: v2
---
2017-01-24 00:05:46 +08:00
< div class = "announcement" > Jan 23, 2017 — < a href = "http://leafletjs.com/2017/01/23/leaflet-1.0.3.html" > Leaflet 1.0.3< / a > , a bugfix release, is out.< / div >
2016-09-28 00:31:58 +08:00
2014-04-30 04:15:06 +08:00
< p > Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps.
ES6 modules & Rollup (#4989)
* WIP ES6 modules & rollup
* WIP ES6 modules & rollup 2
* WIP ES6 modules & rollup 3
* WIP ES6 modules Browser
* WIP ES6 module fixes
* WIP ES6 modules: simpler browser exports
* WIP ES6: refactor CRS/Projection modules, CRS obj -> CRS.Base
* get rid of unnecessary index.js
* WIP ES6 modules, dom events and stuff
* Make linter happy, rollup to dist/
* revert to CRS namespace/class for now
* WIP rollup: export more stuff
* export controls
* rollup: export Layer
* rollup: export DomEvent
* rollup: export more layer types
* rollup: export Popup/Tooltip
* WIP: ES6-ify marker, icon, domutil, draggable.
* ES6-ify gridlayer, tilelayer.
* ES6-ify: Tweak imports-exports, code is now runnable!!
* ES6-ify: Fix scope in some DomUtils
* ES6-ify: Path, fix Popup
* ES6-ify: Lint & cleanup
* ES6-ify map handlers, more linting
* ES6-ify: Icon.Default namespacing
* ES6-ify: Renderers, CircleMarker
* ES6-ify: Circle, Polyline, LineUtil
* ES6-ify: Polygon, Rectangle, LineUtil, PolyUtil, linting
* ES6-ify: SVG.VML
* ES6-ify: DomEvent.Pointer, DomEvent.DoubleTap
* ES6-ify: Linting, make Karma play nice with Rollup
* ES6-ify: More work on fixing bits breaking some unit tests.
* ES6-ify: rollup the version number, fiddled with build scripts
* ES6-ify: Fiddle with test scripts
* ES6-ify: cleanup (refs to global L, imports from (DOM)Util), prevent cyclic loop on Map imports
* ES6-ify: More cleanup of (DOM)Util/Browser/DomEvent imports
* ES6ify: Use rollup's "legacy" option for ES3 (IE8) builds
* ES6-ify: Clean up build scripts, fix CONTRIBUTING.md instructions
* Typo
* ES6-ify: minor fixes and lefovers after rebasing on top of 1.0.2
* ES6-ify: upgrade to rollup 0.38 for proper IE8 builds, fix L.SVG.VML
* Make linter happy.
* ES6: Fixing typos and sxrew-ups after big rebase
* Fix symlink for debugging scripts
* ES6: Cleanup old build scripts
* ES6-ify: Update build system to include git rev in L.version
* ES6-ify: re-enable unit tests replacing L.Path with L.Polyline
* Export Path
* ES6ify: cleanup old banner file
* ES6-ify: whitespace in var declarations
* ES6-ify: Export toTransformation as L.transformation
* ES6-ify: cleanup L.transform exports
* ES6-ify: "import Util" in Transformation and SVG.VML
2017-01-30 18:35:16 +08:00
Weighing just about < abbr title = "38 KB gzipped — that's 133 KB minified and 378 KB in the source form, with 10 KB of CSS (2 KB gzipped) and 11 KB of images." > 38 KB of JS< / abbr > ,
2014-04-30 04:15:06 +08:00
it has all the mapping < a href = "#features" > features< / a > most developers ever need.< / p >
2014-04-22 21:51:21 +08:00
< p > Leaflet is designed with < em > simplicity< / em > , < em > performance< / em > and < em > usability< / em > in mind.
It works efficiently across all major desktop and mobile platforms,
can be extended with lots of < a href = "plugins.html" > plugins< / a > ,
has a beautiful, easy to use and < a title = "Leaflet API reference" href = "reference.html" > well-documented API< / a >
and a simple, readable < a title = "Leaflet source code repository on GitHub" href = "https://github.com/Leaflet/Leaflet" > source code< / a > that is a joy to
< a title = "A guide to contributing to Leaflet" href = "https://github.com/Leaflet/Leaflet/blob/master/CONTRIBUTING.md" > contribute< / a > to.< / p >
2014-04-23 19:08:14 +08:00
2014-04-30 04:15:06 +08:00
< div id = "map" class = "map map-home" style = "height: 300px; margin-top: 50px" > < / div >
2014-04-22 21:51:21 +08:00
2014-04-30 06:24:41 +08:00
< p > Here we create a map in the < code > 'map'< / code > div, add < abbr title = "Here we use OpenStreetMap tiles, but Leaflet doesn't force you to — use whatever works for you, it's open source!" > tiles of our choice< / abbr > , and then add a marker with some text in a popup:< / p >
2014-04-22 21:51:21 +08:00
2014-04-23 18:50:20 +08:00
< pre class = "basic-code javascript" > < code > var map = L.map('map').setView([51.505, -0.09], 13);
2014-04-22 21:51:21 +08:00
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
2014-04-30 06:24:41 +08:00
attribution: '& copy; < a href="http://osm.org/copyright"> OpenStreetMap< /a> contributors'
2014-04-22 21:51:21 +08:00
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
2014-04-23 18:50:20 +08:00
.bindPopup('A pretty CSS3 popup.< br> Easily customizable.')
2014-04-22 21:51:21 +08:00
.openPopup();< / code > < / pre >
2017-05-05 20:56:08 +08:00
< p > Learn more with the < a href = "examples/quick-start/" > quick start guide< / a > , check out < a href = "examples.html" > other tutorials< / a > ,
2014-04-22 21:51:21 +08:00
or head straight to the < a href = "reference.html" > API documentation< / a > .
2014-04-23 04:54:27 +08:00
If you have any questions, take a look at the < a href = "https://github.com/Leaflet/Leaflet/blob/master/FAQ.md" > FAQ< / a > first.< / p >
2014-04-30 04:15:06 +08:00
< / div >
2014-04-30 18:17:20 +08:00
< h2 class = "usedby-title" > Trusted by the best< / h2 >
2014-04-30 04:15:06 +08:00
< div class = "usedby" >
2015-06-30 21:46:58 +08:00
< div class = "container" >
2015-07-01 15:04:54 +08:00
< a class = "logo logo-github" href = "https://github.com" > GitHub< / a >
< a class = "logo logo-foursquare" href = "http://foursquare.com" > foursquare< / a >
< a class = "logo logo-pinterest" href = "https://www.pinterest.com" > Pinterest< / a >
2015-07-01 22:24:15 +08:00
< a class = "logo logo-facebook" href = "https://www.facebook.com/" > Facebook< / a >
2015-07-01 15:04:54 +08:00
< a class = "logo logo-evernote" href = "https://evernote.com" > Evernote< / a >
2015-07-01 22:09:57 +08:00
< a class = "logo logo-etsy" href = "https://www.etsy.com/" > Etsy< / a >
2015-07-01 22:24:15 +08:00
< a class = "logo logo-flickr" href = "https://www.flickr.com/" > Flickr< / a >
< a class = "logo logo-500px" href = "https://500px.com" > 500px< / a >
< a class = "logo logo-datagov" href = "http://www.data.gov/" > Data.gov< / a >
< a class = "logo logo-european-commission" href = "http://ec.europa.eu/" > European Commission< / a >
2015-07-01 15:04:54 +08:00
< a class = "logo logo-wpost" href = "https://www.washingtonpost.com" > The Washington Post< / a >
< a class = "logo logo-ftimes" href = "http://www.ft.com" > Financial Times< / a >
< a class = "logo logo-npr" href = "http://www.npr.org" > NPR< / a >
< a class = "logo logo-usatoday" href = "http://www.usatoday.com" > USA Today< / a >
2015-07-01 22:09:57 +08:00
< a class = "logo logo-nps" href = "http://www.nps.gov/" > National Park Service< / a >
< a class = "logo logo-ign" href = "http://ign.com" > IGN.com< / a >
2015-06-30 21:46:58 +08:00
< / div >
2014-04-30 04:15:06 +08:00
< / div >
< div class = "container" >
2014-04-24 20:44:11 +08:00
< h2 id = "features" > Features< / h2 >
2014-04-23 04:54:27 +08:00
2015-07-01 15:33:12 +08:00
< p > Leaflet doesn't try to do everything for everyone. Instead it focuses on making < em > the basic things work perfectly< / em > .< / p >
2014-04-23 04:54:27 +08:00
2014-04-24 21:24:41 +08:00
< div class = "features clearfix" >
2015-09-05 00:18:14 +08:00
< div class = "no-break" >
< h3 > Layers Out of the Box< / h3 >
< ul >
< li > Tile layers, WMS< / li >
< li > Markers, Popups< / li >
< li > Vector layers< span class = "quiet" > : polylines, polygons, circles, rectangles< / span > < / li >
< li > Image overlays< / li >
< li > GeoJSON< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Interaction Features< / h3 >
< ul >
< li > Drag panning with inertia< / li >
< li > Scroll wheel zoom< / li >
< li > Pinch-zoom on mobile< / li >
< li > Double click zoom< / li >
< li > Zoom to area < span class = "quiet" > (shift-drag)< / span > < / li >
< li > Keyboard navigation< / li >
< li > Events< span class = "quiet" > : click, mouseover, etc.< / span > < / li >
< li > Marker dragging< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Visual Features< / h3 >
< ul >
< li > Zoom and pan animation< / li >
< li > Tile and popup fade animation< / li >
< li > Very nice default design < span class = "quiet" > for markers, popups and map controls< / span > < / li >
< li > Retina resolution support< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Customization Features< / h3 >
< ul >
< li > Pure CSS3 popups and controls < span class = "quiet" > for easy restyling< / span > < / li >
< li > Image- and HTML-based markers< / li >
< li > < span class = "quiet" > A simple interface for< / span > custom map layers and controls< / li >
< li > Custom map projections < span class = "quiet" > (with < code > EPSG:3857/4326/3395< / code > out of the box)< / span > < / li >
< li > Powerful OOP facilities < span class = "quiet" > for extending existing classes< / span > < / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Performance Features< / h3 >
< ul >
< li > Hardware acceleration on mobile < span class = "quiet" > makes it feel as smooth as native apps< / span > < / li >
< li > Utilizing CSS3 features < span class = "quiet" > to make panning and zooming really smooth< / span > < / li >
< li > Smart polyline/polygon rendering < span class = "quiet" > with dynamic clipping and simplification makes it very fast< / span > < / li >
< li > Modular build system< span class = "quiet" > for leaving out features you don't need< / span > < / li >
< li > Tap delay elimination on mobile< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Map Controls< / h3 >
< ul >
< li > Zoom buttons< / li >
< li > Attribution< / li >
< li > Layer switcher< / li >
< li > Scale< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Browser Support< / h3 >
< h4 > Desktop< / h4 >
< ul >
< li > Chrome< / li >
< li > Firefox< / li >
< li > Safari 5+< / li >
< li > Opera 12+< / li >
< li > IE 7– 11< / li >
< / ul >
< / div >
< div class = "no-break" >
< h4 > Mobile< / h4 >
< ul >
< li > Safari for iOS 7+< / li >
< li > Android browser 2.2+, 3.1+, 4+< / li >
< li > Chrome for mobile< / li >
< li > Firefox for mobile< / li >
< li > IE10+ for Win8 devices< / li >
< / ul >
< / div >
< div class = "no-break" >
< h3 > Misc< / h3 >
< ul >
< li > Extremely lightweight< / li >
< li > No external dependencies< / li >
< / ul >
< / div >
2014-04-23 18:50:20 +08:00
< / div >
2014-04-23 04:54:27 +08:00
2015-07-01 15:33:12 +08:00
< p > If you find some feature really missing in Leaflet, first check if there's a < a href = "plugins.html" > plugin for it< / a > . If not, please vote for the feature on the < a href = "https://leaflet.uservoice.com" > Leaflet UserVoice page< / a > .< / p >
2014-04-23 04:54:27 +08:00
2014-04-23 18:50:20 +08:00
< h2 > Getting Involved< / h2 >
2014-04-23 04:54:27 +08:00
2015-07-01 23:34:29 +08:00
< p > Let's create the best mapping library that will ever exist! Leaflet is developed by < a href = "http://agafonkin.com" > Vladimir Agafonkin< / a > of < a href = "http://mapbox.com" > Mapbox< / a > with a team of dedicated < a href = "https://github.com/Leaflet/Leaflet/graphs/contributors" > contributors< / a > .
2014-04-23 18:50:20 +08:00
< a href = "https://github.com/Leaflet/Leaflet" > Pull requests< / a > are always welcome.
However, there are many more ways to get involved with the development of Leaflet.< / p >
2014-04-23 04:54:27 +08:00
2014-04-23 18:50:20 +08:00
< p > You can help the project tremendously by discovering and < a href = "https://github.com/Leaflet/Leaflet/blob/master/CONTRIBUTING.md#reporting-bugs" > reporting bugs< / a > , < a href = "https://github.com/Leaflet/Leaflet/blob/master/CONTRIBUTING.md#improving-documentation" > improving documentation< / a > ,
2015-11-27 18:31:33 +08:00
helping others on < a href = "https://stackoverflow.com/questions/tagged/leaflet" > Stack Overflow< / a > , < a href = "https://gis.stackexchange.com/questions/tagged/leaflet" > GIS Stack Exchange< / a >
2014-04-23 18:50:20 +08:00
and < a href = "https://github.com/Leaflet/Leaflet/issues" > GitHub issues< / a > ,
showing your support for your favorite feature suggestions on < a href = "http://leaflet.uservoice.com" > Leaflet UserVoice page< / a > ,
tweeting to < a href = "http://twitter.com/LeafletJS" > @LeafletJS< / a >
and spreading the word about Leaflet among your colleagues and friends.< / p >
2014-04-23 04:54:27 +08:00
2014-04-23 19:08:14 +08:00
< p > Check out the < a href = "https://github.com/Leaflet/Leaflet/blob/master/CONTRIBUTING.md" > contribution guide< / a > for more information on getting involved with Leaflet development.< / p >
< div class = "social-buttons" >
< iframe src = "http://ghbtns.com/github-btn.html?user=Leaflet&repo=Leaflet&type=watch&count=true" allowtransparency = "true" frameborder = "0" scrolling = "0" width = "104px" height = "20px" > < / iframe >
< a href = "https://twitter.com/LeafletJS" class = "twitter-follow-button" data-show-count = "true" data-show-screen-name = "false" > Follow @LeafletJS< / a >
< script > ! function ( d , s , id ) { var js , fjs = d . getElementsByTagName ( s ) [ 0 ] ; if ( ! d . getElementById ( id ) ) { js = d . createElement ( s ) ; js . id = id ; js . src = "http://platform.twitter.com/widgets.js" ; fjs . parentNode . insertBefore ( js , fjs ) ; } } ( document , "script" , "twitter-wjs" ) ; < / script >
< iframe src = "http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fleafletjs.com&layout=button_count&show_faces=false&width=93&action=like&font=arial&colorscheme=light&height=35" scrolling = "no" frameborder = "0" style = "border:none; overflow:hidden; width:93px; height:20px;" allowTransparency = "true" > < / iframe >
< / div >
2014-04-22 21:51:21 +08:00
< script >
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '© < a href = "http://openstreetmap.org/copyright" > OpenStreetMap< / a > contributors',
osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});
var map = L.map('map').setView([51.505, -0.159], 15).addLayer(osm);
L.marker([51.504, -0.159])
.addTo(map)
.bindPopup('A pretty CSS3 popup.< br / > Easily customizable.')
.openPopup();
< / script >