addMapboxTiles {mapboxapi}R Documentation

Use a Mapbox style in a Leaflet map

Description

See the Mapbox Static Tiles API documentation for more information.

Usage

addMapboxTiles(
  map,
  style_id,
  username,
  style_url = NULL,
  scaling_factor = c("1x", "0.5x", "2x"),
  access_token = NULL,
  layerId = NULL,
  group = NULL,
  options = leaflet::tileOptions(),
  data = leaflet::getMapData(map),
  attribution = TRUE
)

Arguments

map

A map widget object created by leaflet::leaflet()

style_id

The style ID of a Mapbox style

username

A Mapbox username

style_url

A Mapbox style URL

scaling_factor

The scaling factor to use when rendering the tiles. A scaling factor of "1x" (the default) returns 512px by 512px tiles. A factor of "1x" returns 256x256 tiles, and a factor of "2x" returns 1024x1024 tiles.

access_token

Your Mapbox access token; which can be set with mb_access_token().

layerId

the layer ID

group

The name of the group the Mapbox tile layer should belong to (for use in Shiny and to modify layers control in a Leaflet workflow)

options

A list of extra options (optional)

data

The data object used to derive argument values; can be provided to the initial call to leaflet::leaflet()

attribution

If TRUE, pass a standard attribution to leaflet::addTiles(). If FALSE, attribution is NULL. attribution can also be a character string including HTML.

Value

A pointer to the Mapbox Static Tiles API which will be translated appropriately by the leaflet R package.

Examples

## Not run: 

library(leaflet)
library(mapboxapi)

leaflet() %>%
  addMapboxTiles(
    style_id = "light-v9",
    username = "mapbox"
  ) %>%
  setView(
    lng = -74.0051,
    lat = 40.7251,
    zoom = 13
  )

## End(Not run)


[Package mapboxapi version 0.6 Index]