r - `get_map` map函数忽略了ggmap包中的 "source"参数

标签 r ggmap

使用函数 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/

相关文章:

r - 如何在R中分离两个图?

r - ggmap:使用开放街道 map 作为源时出错

r - 使用 ggmap 按值绘制热图

r - 如何使用ggplot绘制美国城市?

r - 如何叠加 contsurvplot 包中的两个 ggplot2 对象?

r - ggplot2 - 设置下限大于最低点

r - Highcharts 中的 dash_styles

r - 在新创建的列中,使用上面行中的值使用 dplyr 计算下一行

反向地理编码速度