Uses rosm::osm.image() to add background tiles. If you are publishing a map using these tiles, make sure to use the proper attribution (e.g., "Copyright OpenStreetMap contributors" when using an OpenStreetMap-based tile set).

annotation_map_tile(
  type = "osm",
  zoom = NULL,
  zoomin = -2,
  forcedownload = FALSE,
  cachedir = NULL,
  progress = c("text", "none"),
  quiet = TRUE,
  interpolate = TRUE,
  data = NULL,
  mapping = NULL,
  alpha = 1
)

GeomMapTile

Arguments

type

The map type (one of that returned by rosm::osm.types)

zoom

The zoom level (overrides zoomin)

zoomin

Delta on default zoom. The default value is designed to download fewer tiles than you probably want. Use -1 or 0 to increase the resolution.

forcedownload

Re-download cached tiles?

cachedir

Specify cache directory

progress

Use progress = "none" to suppress progress and zoom output

quiet

Use quiet = FALSE to see which URLs are downloaded

interpolate

Passed to grid::rasterGrob()

data, mapping

Specify data and mapping to use this geom with facets

alpha

Use to make this layer semi-transparent

Format

An object of class GeomMapTile (inherits from Geom, ggproto, gg) of length 5.

Value

A ggplot2 layer

Examples

library(ggplot2) load_longlake_data() ggplot() + annotation_map_tile(zoom = 13, cachedir = system.file("rosm.cache", package = "ggspatial")) + geom_sf(data = longlake_waterdf, fill = NA, col = "grey50")
#> Zoom: 13