base_map | R Documentation |
fetches a basemap for our map based on the map's bounding box. Includes themes available at: https://leaflet-extras.github.io/leaflet-providers/preview/
base_map(bbox, increase_zoom = 0, basemap = "dark", nolabels = F)
bbox |
bounding box for out map extents generated using st_bbox() and expanded as necessary using expand_bbox(). Bounding box should be in lat/lng (epsg: 4326). |
increase_zoom |
the zoom is automatically calculated for the map but we can increase or decrease the zoom by setting an integer value. |
basemap |
the style of basemap to use. Currently supports 'dark', 'hydda', 'positron', 'voyager', 'wikimedia', 'mapnik', google, google-nobg, google-hybrid, google-terrain, google-satellite, google-road |
nolabels |
if TRUE, removes labels from the basemap. This is only available for some styles. |
a set of tiles to be added to a ggplot object.
# get bounding box for our map library(sf) bbox <- st_bbox(localauth_data) # add to ggplot library(ggplot2) ggplot() + base_map(bbox, increase_zoom = 2, basemap = "google-terrain") + geom_sf(data = localauth_data, fill = NA) + coord_sf(xlim = c(bbox$xmin, bbox$xmax), ylim = c(bbox$ymin, bbox$ymax), crs = 4326) # add straight to ggplot ggplot() + base_map(st_bbox(localauth_data), increase_zoom = 2) + geom_sf(data = localauth_data, fill = NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.