Error when mapping in ggmap with API key (403 Forbidden)

前端 未结 2 1824
南笙
南笙 2020-12-11 05:43

I normally use ggmap to plot points on a simple city map. When doing this today I came up on a new error that forbids me to use the function get_map()

2条回答
  •  时光说笑
    2020-12-11 06:22

    If you're API key is working you can also use library(googleway) to plot interactive maps

    library(googleway)
    
    ## you can use separate API keys for different APIs
    set_key( "GOOGLE_API_KEY", api = "geocode")
    set_key( "GOOGLE_MAP_KEY", api = "map")
    
    ## you can view the keys you have with
    google_keys()
    
    google_map( location = c(52, 0), zoom = 6 )
    

    ## add a marker by geocoding an address
    res <- google_geocode("Buckingham Palace")
    loc <- geocode_coordinates( res )
    
    google_map() %>%
      add_markers(data = loc)
    

提交回复
热议问题