r - 无法通过 get_map() 函数下载地图
问题描述
我需要 get_map 函数的帮助,每次我使用它时,我都无法下载地图
例子:
get_map('Egypt',zoom = 'auto')
download.file(url, destfile = tmp, quiet = !messaging, mode = "wb") 中的错误:无法打开 URL ' http://maps.googleapis.com/maps/api/staticmap?center=Egypt&zoom=10&size= 640x640&scale=2&maptype=terrain&language=en-EN&sensor=false ' 另外:警告消息:在 download.file(url, destfile = tmp, quiet = !messaging, mode = "wb") 中:无法打开 URL ' http://maps .googleapis.com/maps/api/staticmap?center=Egypt&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false ':HTTP 状态为 '403 Forbidden'
解决方案
ggmap
正在使用 Google 地图作为其标准地图源。
目前,ggmap
正在连接的 Google Maps API 需要 lon/lat 坐标(例如,location = c(16.3738,48.2082)
不是位置名称)和一个正常运行且已注册的 Google Maps API 密钥(您register_google(key = "...")
在每个新会话中注册)才能获取地图。
所以,你的完整代码是
library(ggmap)
register_google(key = "...") # with your billing-enabled API key entered here
map <- get_map(location = c(31.2357,30.0444), zoom = 5)
ggmap(map)
有关进一步的故障排除指示,请参阅Github 上的此问题。
推荐阅读
- javascript - 对象集合成对象数组
- android - 从广播接收器更新内部/嵌套 RecyclerView
- asp.net - 如何使用 IHttpContextAccessor 获取当前用户 ID?
- swagger-2.0 - 如何在 Swagger2 中为 POST 请求的请求正文提供多个示例?
- python - 如何在 Python 中初始化继承的类
- python - Pandas Trello JSON 到 XLS - 如何添加和展平清单对象?
- javascript - 在页面上使用组件,布局总是选择默认。无法选择其他布局
- woocommerce - Woocommerce单品页面Hook定制
- python - 当您想将列表/元组输入表单时,您在烧瓶中使用什么 WTForm 字段?
- sql-server - 使用 Dask 的新 to_sql 来提高效率(内存/速度)或替代方法将数据从 dask 数据帧获取到 SQL Server 表中