我已經寫了包googleway訪問谷歌地圖API,你可以指定你的API密鑰。
例如
library(googleway)
key <- "your_api_key"
google_geocode(address = "San Francisco",
key = key)
# $results
# address_components
# 1 San Francisco, San Francisco County, California, United States, SF, San Francisco County, CA, US, locality, political, administrative_area_level_2, political, administrative_area_level_1, political, country, political
# formatted_address geometry.bounds.northeast.lat geometry.bounds.northeast.lng geometry.bounds.southwest.lat
# 1 San Francisco, CA, USA 37.92977 -122.3279 37.69313
# geometry.bounds.southwest.lng geometry.location.lat geometry.location.lng geometry.location_type
# 1 -123.1661 37.77493 -122.4194 APPROXIMATE
# geometry.viewport.northeast.lat geometry.viewport.northeast.lng geometry.viewport.southwest.lat
# 1 37.812 -122.3482 37.7034
# geometry.viewport.southwest.lng place_id types
# 1 -122.527 ChIJIQBpAG2ahYAR_6128GcTUEo locality, political
#
# $status
# [1] "OK"