Skip to content
Extends the R Leaflet package with a Mapbox GL JS plugin to allow easy drawing of vector tile layers.
R JavaScript CSS
Branch: master
Clone or download
Latest commit dec90d1 Mar 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Fix issue #1 Mar 6, 2019
inst Fix issue #1 Mar 6, 2019
man Fix issue #1 Mar 6, 2019
.Rbuildignore Add screenshot Mar 4, 2019
.gitignore Initial working prototype Mar 4, 2019
DESCRIPTION Pass R CMD check Mar 4, 2019
LICENSE Initial working prototype Mar 4, 2019
NAMESPACE API cleanup; add README Mar 4, 2019
README.md Clarify compatibility Mar 14, 2019
leaflet.mapboxgl.Rproj Initial working prototype Mar 4, 2019
sshot.png Add screenshot Mar 4, 2019

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.