static_mapbox | R Documentation |
This function uses the Mapbox Static Maps API to return a pointer to an
"magick-image"
class image or a httr::response object from the static map
image URL.
static_mapbox(
location = NULL,
buffer_dist = 1000,
units = "m",
style_id,
username,
style_url = NULL,
overlay_sf = NULL,
overlay_style = NULL,
overlay_markers = NULL,
longitude = NULL,
latitude = NULL,
zoom = NULL,
width = NULL,
height = NULL,
bearing = NULL,
pitch = NULL,
scale = 0.5,
scaling_factor = c("1x", "2x"),
attribution = TRUE,
logo = TRUE,
before_layer = NULL,
access_token = NULL,
image = TRUE,
strip = TRUE
)
location |
An input location for which you would like to request tiles.
Can be a length-4 vector representing a bounding box, or an |
buffer_dist |
The distance to buffer around an input |
units |
Units of |
style_id |
A style ID (required if style_url is |
username |
A Mapbox username (required if |
style_url |
A Mapbox style url; defaults to |
overlay_sf |
The overlay |
overlay_style |
A named list of vectors specifying how to style the sf
overlay. Possible names are "stroke", "stroke-width" (or "stroke_width"),
"stroke-opacity" (or "stroke_opacity"), "fill", and "fill-opacity" (or
"fill_opacity"). The fill and stroke color values can be specified as
six-digit hex codes or color names, and the opacity and width values should
be supplied as floating-point numbers. If overlay_style is |
overlay_markers |
The prepared overlay markers (optional). See the function prep_overlay_markers for more information on how to specify a marker overlay. |
longitude , latitude |
The longitude and latitude of the map center. If an overlay is supplied, the map will default to the extent of the overlay unless longitude, latitude, and zoom are all specified. |
zoom |
The map zoom. The map will infer this from the overlay unless longitude, latitude, and zoom are all specified. |
width , height |
The map width and height; defaults to |
pitch , bearing |
The map pitch and bearing; defaults to |
scale |
ratio to scale the output image; |
scaling_factor |
The scaling factor of the tiles; either |
attribution |
Controls whether there is attribution on the image.
Defaults to |
logo |
Controls whether there is a Mapbox logo on the image. Defaults to
|
before_layer |
A character string that specifies where in the hierarchy
of layer elements the overlay should be inserted. The overlay will be
placed just above the specified layer in the given Mapbox styles. List
layer ids for a map style with |
access_token |
A Mapbox access token; which can be set with mb_access_token. |
image |
If |
strip |
If |
A pointer to an image of class "magick-image"
if image = TRUE
.
The resulting image can be manipulated further with functions from the
magick package.
## Not run:
library(mapboxapi)
points_of_interest <- tibble::tibble(
longitude = c(-73.99405, -74.00616, -73.99577, -74.00761),
latitude = c(40.72033, 40.72182, 40.71590, 40.71428)
)
prepped_pois <- prep_overlay_markers(
data = points_of_interest,
marker_type = "pin-l",
label = 1:4,
color = "fff"
)
map <- static_mapbox(
style_id = "streets-v11",
username = "mapbox",
overlay_markers = prepped_pois,
width = 1200,
height = 800
)
map
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.