Create Interactive Web Maps with the JavaScript 'Leaflet' Library

Create and customize interactive maps using the 'Leaflet' JavaScript library and the 'htmlwidgets' package. These maps can be used directly from the R console, from 'RStudio', in Shiny apps and R Markdown documents.

Build Status

Leaflet is an open-source JavaScript library for interactive maps. This R package makes it easy to create Leaflet maps from R.

m = leaflet() %>% addTiles()
m  # a map with the default OSM tile layer
m = m %>% setView(-93.65, 42.0285, zoom = 17)
m %>% addPopups(-93.65, 42.0285, 'Here is the <b>Department of Statistics</b>, ISU')


You can install this package from CRAN, or the development version from Github:

# CRAN version
# Or Github version
if (!require('devtools')) install.packages('devtools')


In addition to the usual R package documentation, we also have extensive docs and examples at: You may use Github issues to file bug reports or feature requests, and ask questions on StackOverflow or in the Shiny mailing list.


To make additions or modifications to the JavaScript htmlwidgets binding layer, you must use Grunt to build and test. Please make sure Node.js is installed on your system, then run:

npm install -g grunt-cli
npm install

Now you can build/minify/lint/test using grunt build, or run in "watch" mode by just running grunt. JS sources go into javascript/src and tests go into javascript/tests.


This package is licensed to you under the terms of the GNU General Public License version 3 or later.

Copyright 2013-2015 RStudio, Inc.


leaflet 1.1.0

  • Add support for sf. sf, sfc, and sfg classes are supported with POINT, LINESTRING, MULTILINESTRING, POLYGON, and MULTIPOLYGON geometries (note that MULTIPOINT is not currently supported).

  • Added support for Crosstalk (

  • Added option to highlight polygons, polylines, circles, and rectangles on hover (use highlightOptions parameter).

  • Fix behavior when data contains NA points, or zero rows. Previously this would cause an error.

  • Added popupOptions parameter to all markers and shape layers.

  • Upgraded existing plugins to their respective latest versions and added missing/new functionality from those plugins. (PR #293)

  • Added Proj4Leaflet plugin (PR #294).

  • Added EasyButton plugin (PR #295).

  • Added Graticule plugin (PR #293).

  • Color palette improvements. All color palette functions now support viridis palettes ("viridis", "magma", "inferno", and "plasma").

  • Color palette functions now support reversing the order in which colors are used, via reverse=TRUE.

  • colorFactor no longer interpolates qualitative RColorBrewer palettes, unless the number of factor levels being mapped exceeds the number of colors in the specified RColorBrewer palette. (Issue #300)

  • Upgrade leaflet.js to (PR #359)

  • Added a way for the Map instance to be instantiated via a factory.

leaflet 1.0.2

  • When used with leafletProxy, fitBounds did not return its input object as output, so magrittr chains would break after fitBounds was called.

  • Add addMeasure()/removeMeasure() functions to allow users to measure lines and areas, via the leaflet-measure plugin by @ljagis. (PR #171. Thanks, Kenton Russell!)

  • Add input${mapid}_center Shiny event.

  • Add support for labels on most layers, that show either statically or on hover. (PR #181. Thanks Bhaskar Karambelkar!)

  • Add support for markers with configurable colors and icons, via the Leaflet.awesome-markers plugin by @lvoogdt. See ?addAwesomeMarkers. (PR #184. Great work, Bhaskar!)

  • Add support for the Leaflet.Terminator plugin by @joergdietrich. Overlays day and night regions on a map. See ?addTerminator. (PR #184, thanks Bhaskar!)

  • Add support for Leaflet.SimpleGraticule plugin by @ablakey. See ?addSimpleGraticule. (PR #184, thanks again Bhaskar!)

  • Add support for Leaflet.MagnifyingGlass plugin by @bbecquet. Adds a configurable magnifying glass that displays the area under the cursor at an increased zoom level. See ?addMagnifyingGlass. (PR #184, still Bhaskar!)

  • Add support for Leaflet-MiniMap plugin by @Norkart. Adds a mini map to the corner that can be used to see or change the bounds of the main map. See ?addMiniMap. (PR #184, Bhaskar again!)

  • addScaleBar and related functions added, for showing Leaflet's built-in scale bar in one of the corners of the map. (PR #201. Thanks Kent Johnson!)

leaflet 1.0.1

  • Fix #242: Compatibility with htmlwidgets 0.6 (thanks byzheng).

leaflet 1.0.0

  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1.0 by Joe Cheng, a year ago

Report a bug at

Browse source code at

Authors: Joe Cheng [aut, cre], Bhaskar Karambelkar [aut], Yihui Xie [aut], Hadley Wickham [ctb], Kenton Russell [ctb], Kent Johnson [ctb], jQuery Foundation and contributors [ctb, cph] (jQuery library), Vladimir Agafonkin [ctb, cph] (Leaflet library), CloudMade [cph] (Leaflet library), Leaflet contributors [ctb] (Leaflet library), Leaflet Providers contributors [ctb, cph] (Leaflet Providers plugin), Brandon Copeland [ctb, cph] (leaflet-measure plugin), Jacob Toye [ctb, cph] (Leaflet.label plugin), Joerg Dietrich [ctb, cph] (Leaflet.Terminator plugin), Benjamin Becquet [ctb, cph] (Leaflet.MagnifyingGlass plugin), Norkart AS [ctb, cph] (Leaflet.MiniMap plugin), L. Voogdt [ctb, cph] (Leaflet.awesome-markers plugin), Daniel Montague [ctb, cph] (Leaflet.EasyButton plugin), Kartena AB [ctb, cph] (Proj4Leaflet plugin), Robert Kajic [ctb, cph] (leaflet-locationfilter plugin), Mapbox [ctb, cph] (leaflet-omnivore plugin), Michael Bostock [ctb, cph] (topojson), RStudio [cph]

Documentation:   PDF Manual  

GPL-3 license

Imports base64enc, crosstalk, htmlwidgets, htmltools, magrittr, markdown, methods, png, RColorBrewer, raster, scales, sp, stats, viridis

Suggests knitr, maps, sf, shiny, testit, rgdal, rgeos, R6, RJSONIO, purrr, testthat

Imported by PWFSLSmoke, QRAGadget, SpatialEpiApp, amt, eAnalytics, futureheatwaves, geoSpectral, inlmisc, jpmesh, jpndistrict, leaflet.minicharts, leafletCN, lingtypology, mapedit, mapr, mapview, metScanR, neotoma, ppcSpatial, robis, stationaRy, teachingApps, tmap, trackeR, windfarmGA, worldmet.

Depended on by leaflet.esri, leaflet.extras, wallace.

Suggested by RSurvey, RgoogleMaps, Rnightlights, blscrapeR, cancensus, cycleRtools, geojsonio, lawn, macleish, manipulateWidget, mapsapi, nyctaxi, openadds, owmr, parlitools, rdefra, rdwd, rnoaa, statesRcontiguous, synthACS, tigris, tilegramsR, wellknown.

Enhanced by mregions.

See at CRAN