简体   繁体   中英

Error in get_map using ggmap in R

About 90% of the time, when using get_map in ggmap , I get the following error. Can someone please tell me why?

map <- get_map(location = 'Australia', zoom = 4)

Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL ' http://maps.googleapis.com/maps/api/staticmap?center=Australia&zoom=4&size=%20640x640&scale=%202&maptype=terrain&sensor=false ' In addition: Warning message: In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open: HTTP status was '403 Forbidden'

The problem is likely related to your API project not being authorized by Google.

An API project is easy to create, and get authorized:
Click this link and choose create. Alternatively choose select if you already have a created project, but just need to activate the API. After that choose "Enable". After that your code should work.

Link again: https://console.developers.google.com/apis/api/static_maps_backend?project=_

403错误是因为Google现在要求用户注册并使用(免费)api密钥。

The "zoom = 4" is, per documentation, "reserved for google business users only." I can't find much documented on why this would work intermittently or at all for a non-business user, but that's my best guess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM