library(mapdeck)

What is Mapdeck?

Mapdeck is a combination of Mapbox and Deck.gl

Why did you build it?

Because Deck.gl is one of the most user-friendly WebGL javascript libraries and can produce some beautiful maps. And it integrates nicely with Mapbox.

The basics

You need a Mapbox Access Token to load a map. Then call mapdeck(token = token) to give you a map

key <- 'abc'    ## put your own token here
mapdeck(token = key)

You can make your token available ‘globally’ to all mapdeck() calls by either

  1. using set_token(), which sets the token as an option
  2. having the token in your environment (e.g., using Sys.setenv() ) with the key one of “MAPBOX_TOKEN”,“MAPBOX_KEY”,“MAPBOX_API_TOKEN”, “MAPBOX_API_KEY”, “MAPBOX”, “MAPDECK”

Here’s an example using set_token()

set_token('abc')
mapdeck_tokens()
#  Mapdeck tokens
#   -  mapbox : abc

You can style the map using any mapbox style template styles, or you can create one of your own

mapdeck(token = key, style = 'mapbox://styles/mapbox/dark-v9')

I’ve provided a convenience function to select one of the mapbox defined styles

mapdeck_style(style = 'dark')

Once you have a map you can start adding layers through the various add_*() functions (there is an example of each one in this vignette).

All details about layers, colours, tips & triks, etc, are here