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 applications and R Markdown documents.


An R Interface to Leaflet Maps

R build status CRAN RStudio mirror downloads RStudio community

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

library(leaflet)
m = leaflet() %>% addTiles()
m  # a map with the default OSM tile layer

m = m %>% setView(-93.65, 42.0285, zoom = 17)
m

m %>% addPopups(-93.65, 42.0285, 'Here is the <b>Department of Statistics</b>, ISU')

Installation

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

# CRAN version
install.packages('leaflet')

# Or Github version
if (!require('devtools')) install.packages('devtools')
devtools::install_github('rstudio/leaflet')

Documentation

In addition to the usual R package documentation, we also have extensive docs and examples at: https://rstudio.github.io/leaflet/

Development

leaflet's JavaScript build tools use Node.js, along with yarn to manage the JavaScript packages.

Install yarn using the official instructions.

You can test that Node.js and yarn are installed properly by running the following commands:

node --version
yarn --version

To make additions or modifications to the JavaScript htmlwidgets binding layer, you must have all Node.js dependencies installed. Now you can build/minify/lint/test using yarn build, or run in "watch" mode by just running yarn watch. JS sources go into javascript/src and tests go into javascript/tests.

# install dependencies
yarn

# compile
yarn build

# watch
yarn watch

License

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

Copyright 2013-2015 RStudio, Inc.

Reference manual

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

install.packages("leaflet")

2.2.3 by Garrick Aden-Buie, a year ago


https://rstudio.github.io/leaflet/, https://github.com/rstudio/leaflet


Report a bug at https://github.com/rstudio/leaflet/issues


Browse source code at https://github.com/cran/leaflet


Authors: Joe Cheng [aut] , Barret Schloerke [aut] , Bhaskar Karambelkar [aut] , Yihui Xie [aut] , Garrick Aden-Buie [aut, cre] (ORCID: , Hadley Wickham [ctb] , Kenton Russell [ctb] , Kent Johnson [ctb] , Vladimir Agafonkin [ctb, cph] (Leaflet library) , CloudMade [cph] (Leaflet library) , Leaflet contributors [ctb] (Leaflet library) , Brandon Copeland [ctb, cph] (leaflet-measure 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) , Posit Software , PBC [cph, fnd]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports crosstalk, htmltools, htmlwidgets, jquerylib, leaflet.providers, magrittr, methods, png, raster, RColorBrewer, rlang, scales, sf, stats, viridisLite, xfun

Suggests knitr, maps, purrr, R6, RJSONIO, rmarkdown, s2, shiny, sp, terra, testthat


Imported by AirExposure, AirMonitor, AtlasMaker, CARBayesST, CopernicusMarine, DisasterAlert, DonutMap, DrivePlotR, GISSB, GapAnalysis, IceSat2R, LifemapR, MBGapp, MarineChain, MazamaLocationUtils, Poly4AT, QRAGadget, RLumShiny, Rlibkdv, SHARK4R, SPARTAAS, SSDM, SeaGraphs, StormR, Tivy, UnalR, WhatsR, antaresViz, avstrat, bamm, bayesmove, bcdata, bivariateLeaflet, bluebike, camtrapR, commecometrics, comorosmaps, convergEU, damAOI, drhutools, eAnalytics, eph, epiCo, epiflows, epiviz, ezTrack, fitbitViz, gatoRs, geoAr, geocmeans, geodrawr, geospatialsuite, glossa, greenR, gwpcormapper, icardaFIGSr, jpmesh, leafdown, leafem, leafgl, leaflegend, leaflet.minicharts, leafpm, leafsync, lingtypology, mapSpain, mapboxapi, mapedit, mappingAS, mapview, mardist, meltt, mmaqshiny, navigation, neotoma2, occCite, ofpetrial, openairmaps, openrouteservice, pannotator, pargasite, pbr, pkmapr, ppcSpatial, qualmap, rcrimeanalysis, refdb, refuginator, rgee, ridigbio, robis, sae4health, semnar, sits, smartmap, spatialCatalogueViewer, stCEG, starsTileServer, stppSim, suwo, tabs, tmap, toxEval, trackeR, transittraj, valhallr, valuemap, vectorsurvR, webmap.

Depended on by RchivalTag, gde, leaflet.extras, leaflet.extras2, leaftime, wallace.

Suggested by BORG, BeeBDC, ColOpenData, ENMTools, EpiQuestionR, FedData, GTFSwizard, HYPEtools, ICESat2VegR, MetricGraph, OPCC, R4VN, RgoogleMaps, USAboundaries, VasGBIF, agricolaeplotr, amt, berryFunctions, cancensus, catchmentACS, countryatlas, covid19br, csmaps, csodata, ct, cubble, dartR, dartR.base, dartR.popgen, eSDM, echarts4r, echarty, edr4r, fastgeojson, findSVI, floodflow, fude, geeLite, geofi, geojsonio, geslaR, getRad, gmwmx2, hexify, hydflood, hydrogeofetch, iheiddown, jpmap, lakefetch, lcars, leafpop, linkeR, localdatasus, locatr, lterdatasampler, macleish, manipulateWidget, manureshed, mapgl, mappestRisk, mapsapi, mdsr, mongolmaps, mosaic, move, mregions2, nhdplusTools, nlgeocoder, npphen, parzer, pct, pcutils, pdxTrees, pep725, phenocamr, pliman, positron.tutorials, quadkeyr, rapr, rasterList, rbranding, rdwd, reactable, redlistr, repr, rfars, rice, rnrfa, rstac, rtrek, scapesClassification, segclust2d, shiny.fluent, shiny.react, shiny.semantic, shinyscholar, slopes, snotelr, soilKey, spCF, spacemodR, spatialrisk, stacr, stats19, steves, stplanr, surveyPrev, surveydown, terra, tidytransit, tigris, tikatuwq, tilegramsR, tiler, tipsae, tricolore, ukpolice, ursa, villager, windfarmGA, worldmet, wpeR, zonebuilder.


See at CRAN