使用函数 get_map()
时,尽管我使用参数“source”,但我收到一条错误提示,提示我提供 google-API-key:
location = colMeans(city[,c('coords_x1', 'coords_x2')])#mitte
names(location) <- c('lat', 'lon')
get_map(location = location, source='osm')
note : locations should be specified in the lon/lat format, not lat/lon.
Error: Google now requires an API key.
See ?register_google for details.
似乎该参数被忽略了。
最佳答案
解决方案在于查询中使用“位置”的方式。只要没有提供 bbox
,ggmap 就会在 google 中查找正确的边界框。此后就会出现错误。因此,以下代码有效:
bbox <- make_bbox(stadt$coords_x1, stadt$coords_x2, f = .05)
map <- get_map(location = bbox, source='osm')
ggmap(map) + geom_point(data=stadt, aes(x=coords_x1, y=coords_x2, color=akaQuote))
使用 OSM 作为源,必须将边界框传递给 get_map
函数。
关于r - `get_map` map函数忽略了ggmap包中的 "source"参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56456045/