Skip to contents

A new tmap mode, enabled via tmap_mode("mapbox").

Author

Martijn Tennekes mtennekes@gmail.com

Examples

# \donttest{
library(tmap)
library(tmap.mapgl)
# getting API: https://walker-data.com/mapgl/articles/getting-started.html
# check API envir var: Sys.getenv("MAPBOX_PUBLIC_TOKEN")

tmap_mode("mapbox")
#>  tmap mode set to "mapbox".
tm_shape(World) +
  tm_polygons("HPI", fill.scale = tm_scale_intervals(values = "brewer.rd_yl_gn"))
#> Error in mapgl::mapboxgl(center = c(0, 0), zoom = zoom, pitch = o$pitch,     style = style): A Mapbox access token is required. Get one from your account at https://www.mapbox.com, and do one of the following:
#>  Run `usethis::edit_r_environ()` and add the line MAPBOX_PUBLIC_TOKEN='your_token_goes_here';
#>  Install the mapboxapi R package and run `mb_access_token('your_token_goes_here', install = TRUE)`
#>  Alternatively, supply your token to the `access_token` parameter in this function or run `Sys.setenv(MAPBOX_PUBLIC_TOKEN='your_token_goes_here') for this session.

tm_shape(NLD_dist) +
  tm_polygons("employment_rate",
    fill.scale = tm_scale_intervals(values = "scico.roma"),
    lwd = 0.1) +
tm_shape(NLD_muni) +
  tm_polygons(fill = NULL, lwd = 1) +
tm_mapbox(pitch = 60) +
tm_basemap(.tmap_providers$dark)
#> Error in mapgl::mapboxgl(center = ll, zoom = zoom, pitch = o$pitch, style = style): A Mapbox access token is required. Get one from your account at https://www.mapbox.com, and do one of the following:
#>  Run `usethis::edit_r_environ()` and add the line MAPBOX_PUBLIC_TOKEN='your_token_goes_here';
#>  Install the mapboxapi R package and run `mb_access_token('your_token_goes_here', install = TRUE)`
#>  Alternatively, supply your token to the `access_token` parameter in this function or run `Sys.setenv(MAPBOX_PUBLIC_TOKEN='your_token_goes_here') for this session.
# }