Installation and use of R language ggmap package

R language GGMap package installation and use
Ggmap is a map drawing package that calls the Google Maps API via the get_map function.
1 The first attempt went wrong
At the beginning, get_map was used to fetch the map data directly in R. However, an error occurred. The interface to display the function request refused our request (HTTP error code: 403).

map=get_map(location='San Fransico',maptype='roadmap',zoom=12)

URL: zoom=12& size=640x640& scale=2& maptype=roadmap& language=en-EN& sensor=false
2 Baidu Discovery
From July 16, 2018, Google will limit the number of API requests, charge fees for exceeding the limit, and make it mandatory for all projects to use the official API Key. Without the API Key, the quality of the map may degrade or the map will not work. The API key must be associated with a credit card, and if the limit is exceeded, Google will start charging from the credit card. The search giant first offered users a $200 a month credit for free. Google slashed the number of free requests, from 25,000 per day to 28,000 per month, or about 1,000 per day, to a quarter of that. Google users who do not apply for a settlement account can only access the interface once a day.
3. Solving problems
So errors occur because of the lack of interface in the request URL key, to apply for a key in the Google maps developer platform:
We also found that we need to associate the credit card account, that is, the account that needs to be cleared by the Google map interface. After completing a series of applications, we found through the URL that to retrieve this function, we need to enable the staticmap interface. After enabling the interface, we got the KEY of the staticmap interface, but we found that the package we just downloaded directly in R could not add the KEY parameter to the URL. Later, it was found that someone on GitHub had updated the ggmap package. Then remove the ggmap package installed previously, install the latest ggmap package from GitHub, and directly enter the code in R to install:

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")
register_google(key=”your google map API key”)

Add the KEY parameter to register_google() and call the get_map() function to get the map data. If you get an error message that register_google is not register_google, you have not successfully installed the GGMap package from GitHub.
When I call get_map(), I find an error prompting HTTP request to send REQUEST_DENIED. It was found on StackOverflow that Google map still needs to apply for Geocoding API interface. After applying for the interface, it should be ok to call get_map.
1, ggmap packet address:
2, methods other than Google maps, can also study the openstreetmap:

Read More: