Skip to content
Extends the R Leaflet package with a Mapbox GL JS plugin to allow easy drawing of vector tile layers.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
inst
man
.Rbuildignore
.gitignore
DESCRIPTION
LICENSE
NAMESPACE
README.md
leaflet.mapboxgl.Rproj
sshot.png

README.md

leaflet.mapboxgl

Provides an R interface to extend the R Leaflet package with the Mapbox GL Leaflet plugin.

Compatibility

WebGL support is required. Most modern web browsers are supported, but IE11 may not work.

RStudio 1.1 on Windows and Linux do not support WebGL and will not work. RStudio 1.1 for Mac should work.

RStudio 1.2 will work if the rendering engine is set to Desktop OpenGL, which is the default on many systems. If your maps fail to render, you can try changing the rendering engine from the default value of "Auto-detect" to "Desktop OpenGL" by going to Tools | Global Options | General | Advanced | Rendering Engine. (Tip: If this puts your IDE into an unusable state, holding Ctrl during startup will bring up a dialog that lets you revert the Rendering Engine setting to "Auto-detect".)

Installation

This package is not yet available on CRAN.

devtools::install_github("rstudio/leaflet.mapboxgl")

Usage

First, you must provide your Mapbox access token as a global R option. (If you are using non-Mapbox datasource, you still need to provide a value, but it can just be NA.)

options(mapbox.accessToken = "...")

Then, create your Leaflet map, and call the addMapboxGL function.

library(leaflet)
library(leaflet.mapboxgl)

leaflet(quakes) %>%
  addMapboxGL(style = "mapbox://styles/mapbox/streets-v9") %>%
  addCircleMarkers(weight = 1, fillOpacity = 0, radius = 3)

Screenshot of map

License

MIT

You can’t perform that action at this time.