我尝试使用以下显示的方法来使用visible
参数,以比zoom
更好地控制'get_googlemap'范围,但没有成功。有没有可行的方法?谢谢。
library(tidyverse)
library(ggmap)
# static map with ggmap
# boundaries of continental US
# conforms to the ggmap docs
bbox = c(left=-124.848974, bottom=24.396308, right = -66.885444, top= 49.384358)
basemap <- get_googlemap(maptype = "roadmap", visible = as.data.frame(t(matrix(bbox,nrow=2))))
#> visible argument untested.
#> Source : https://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=2&maptype=roadmap&visible=24.396308,-124.848974%7C49.384358,-66.885444&key=xxx-0PA
#ggmap(basemap)
# renders default Houston metro
# conforms to the ggmap docs
# the towns shown below do return valid coordinates with geocode()
basemap <- get_googlemap(maptype = "roadmap", visible = c("lubec,ME","capetown,CA"))
#> visible argument untested.
#> Source : https://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=2&maptype=roadmap&visible=lubec,ME%7Ccapetown,CA&key=xxx-0PA
# ggmap(basemap)
# renders default Houston metro
# This is a character string which manually creates a URL similar
# to what is shown in the viewports section of the developer guide.
# https://developers.google.com/maps/documentation/maps-static/dev-guide
# It generates the same URL as above.
basemap <- get_googlemap(maptype = "roadmap", visible = "lubec,ME%7capetown,CA")
#> visible argument untested.
#> Source : https://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=2&maptype=roadmap&visible=lubec,ME%7capetown,CA&key=xxx-0PA
# ggmap(basemap)
# renders default Houston metro