library(mapdeck)
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.
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
set_token()
, which sets the token as an
option
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 & tricks, etc, are here