r - `get_map` 映射函数忽略 ggmap 包中的“source”参数
问题描述
使用该函数时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
函数。
推荐阅读
- java - Spring Boot + Thymeleaf:Summernote 编辑器使我在卡片中的文本显示比需要的低很多
- c# - Crystal Reports 在 Azure 云服务中引发数据库登录失败错误
- javascript - 替换字符串中的所有“\/”
- php - 在 Eloquent 中为每个模型添加关系计数
- haproxy - 带有动态服务器模板的 Cookie 前缀
- rest - 使用方法 auth Yodlee API
- javascript - 更新 Blob 名称
- json - 如何从带有父兄弟姐妹和子字符串的json中提取文本?
- android - 使用 Kotlin 在 Android 中使用 Body 制作 Retrofit2 POST
- c++ - 来自 C++ 的问题理解代码:Concurrency in Action