The functions get_googlemap()
and get_stadia_map()
tries to harmonize the calls to ggmap()
. The objective is
to get interchangeable functions with sensible defaults. For example automatic calculation of the zoom. The function
bbox_lv95()
generates a bbox object compatible with both functions. Before using this function you need to register
your google API key with ggmap::register_google()
. For details consult the documentation of the
Maps Static API and ggmap::get_googlemap()
.
Usage
get_google_map(
bbox,
width = 640,
zoom = "auto",
scale = 2,
language = "de-CH",
color = "bw",
style = c(feature = "all", element = "labels", visibility = "off"),
...
)
Arguments
- bbox
list with item
center = (lon, lat)
as WSG84 coordinates. Additionalwidth
in meters ifzoom = "auto"
. Usebbox_lv95()
to create a compatible bounding box list- width
of resulting map in pixels. Is divided trough scale to calculate size.
- zoom
of tile map as Integer or "auto"
- scale
affects the size of labels.
ggmap::get_googlemap()
multiplies the size with this factor.- language
character string providing language of map labels (for themes with them) in the format "en-EN". not all languages are supported; for those which aren't the default language is used.
- color
color or black-and-white. Changed default to "bw"
- style
character string or named vector to style the map. This is a powerful and complex specification. See Styled Maps in the documentation of the google maps platform
- ...
forwarded to
ggmap::get_googlemap()
Examples
library(ggmap)
#> ℹ Google's Terms of Service: <https://mapsplatform.google.com>
#> Stadia Maps' Terms of Service: <https://stadiamaps.com/terms-of-service/>
#> OpenStreetMap's Tile Usage Policy: <https://operations.osmfoundation.org/policies/tiles/>
#> ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
ggmap::register_google(Sys.getenv("GGMAP_GOOGLE_API_KEY"))
bb <- bbox_lv95(2683141, 1249040, 500) # site Zch_Stamfenbachstrasse
get_google_map(bb) %>% ggmap::ggmap()
#> ℹ <https://maps.googleapis.com/maps/api/staticmap?center=47.386943,8.53975&zoom=15&size=320x320&scale=2&maptype=terrain&language=de-CH&style=feature:all%7Celement:labels%7Cvisibility:off&key=xxx>