Unlimited learning, half price | 50% off
Get 50% off unlimited learning

⚠️There's a newer version (2.2.2) of this package.Take me there.

An R Interface to Leaflet Maps

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: http://rstudio.github.io/leaflet You may use Github issues to file bug reports or feature requests, and ask questions on StackOverflow or in the Shiny mailing list.

Development

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.

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.

Copy Link

Version

Install

install.packages('leaflet')

Monthly Downloads

94,640

Version

2.0.0

License

GPL-3

Maintainer

Joe Cheng

Last Published

April 20th, 2018

Functions in leaflet (2.0.0)

breweries91

Selected breweries in Franconia
dispatch

Extension points for plugins
derivePolygons

Given a data object and lng/lat arguments (which may be NULL [meaning infer from data], formula [which should be evaluated with respect to the data], or vector data [which should be used as-is]) return a spatial object
easyButtonState

Create an easyButton statestate
leafletOutput

Wrapper functions for using leaflet in shiny
tileOptions

Extra options for map elements and layers
previewColors

Color previewing utility
mapOptions

Set options on a leaflet map object
expandLimits

Notifies the map of new latitude/longitude of items of interest on the map
filterNULL

remove NULL elements from a list
leafletProxy

Send commands to a Leaflet instance in a Shiny app
colorNumeric

Color mapping
leafletDependencies

Various leaflet dependency functions for use in downstream packages
awesomeIconList

Make awesome-icon set
makeAwesomeIcon

Make Awesome Icon
iconList

Make icon set
awesomeIcons

makeIcon

Define icon sets
gadmCHE

Administrative borders of Switzerland (level 1)
providers

Providers
addControl

Graphics elements and layers
setView

Methods to manipulate the map widget
providers.details

Providers Details
leaflet-imports

Objects imported from other packages
showGroup

Show or hide layer groups
validateCoords

Utility function to check if a coordinates is valid
leaflet

Create a Leaflet map widget
removeControl

Remove elements from a map
safeLabel

Sanitize textual labels
addGraticule

addSimpleGraticule

addLegend

Add a color legend to a map
addMeasure

Add a measure control to the map.
addProviderTiles

Add a tile layer from a known map provider
addRasterImage

Add a raster image as a layer
addLayersControl

Add UI controls to switch layers on and off
addMiniMap

addAwesomeMarkers

Add Awesome Markers
addTerminator

Add a daylight layer on top of the map
derivePoints

Given a data object and lng/lat arguments (which may be NULL [meaning infer from data], formula [which should be evaluated with respect to the data], or vector data [which should be used as-is]) return a lng/lat data frame.
expandLimitsBbox

Same as expandLimits, but takes a polygon (that presumably has a bbox attr) rather than lat/lng.
evalFormula

Evaluate list members that are formulae, using the map data as the environment (if provided, otherwise the formula environment)
addScaleBar

Add or remove a scale bar
icons

Create a list of icon data
createLeafletMap

Legacy functions
atlStorms2005

Atlantic Ocean storms 2005
groupOptions

Set options on layer groups
getMapData

returns the map's data