layer_static_mapbox | R Documentation |
These functions wrap static_mapbox()
and ggspatial::layer_spatial()
or
tmap::tm_rgb()
to support the use of images from the Mapbox Static Maps API as
ggplot2 or
tmap basemaps.
layer_static_mapbox(
location = NULL,
buffer_dist = 1000,
units = "m",
style_id,
username,
style_url = NULL,
overlay_sf = NULL,
overlay_style = NULL,
overlay_markers = NULL,
width = NULL,
height = NULL,
scale = 0.5,
scaling_factor = c("1x", "2x"),
attribution = TRUE,
logo = TRUE,
before_layer = NULL,
access_token = NULL,
...
)
tm_static_mapbox(
location = NULL,
buffer_dist = 1000,
units = "m",
style_id,
username,
style_url = NULL,
overlay_sf = NULL,
overlay_style = NULL,
overlay_markers = NULL,
width = NULL,
height = NULL,
scale = 0.5,
scaling_factor = c("1x", "2x"),
attribution = TRUE,
logo = TRUE,
before_layer = NULL,
access_token = NULL,
...
)
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. |
width , height |
The map width and height; 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. |
... |
additional parameters passed to ggspatial::layer_spatial or tmap::tm_rgb |
This function uses a different approach than get_static_tiles()
. Instead,
layer_static_mapbox()
is based largely on layer_mapbox()
in the snapbox package
(available under a MIT license. There
are a few key differences between layer_static_mapbox()
and
layer_mapbox()
. The "scale" parameter is equivalent to the
"scale_ratio" parameter for snapbox. Setting scale_factor = "2x"
is
equivalent to setting retina = TRUE.
Both functions return basemaps that
are no larger than a single tile (a maximum of 1280 by 1280 pixels).
For tm_static_mapbox()
, tmap::tm_shape is called with projection = 3857
and
tmap::tm_rgb is called with max.value = 1
.
Eli Pousson, eli.pousson@gmail.com
Anthony North, anthony.jl.north@gmail.com
Miles McBain, miles.mcbain@gmail.com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.