Skip to content

Instantly share code, notes, and snippets.

@ellisvalentiner
Last active September 21, 2016 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ellisvalentiner/3abd6563c7edf4e03fc562629df76a40 to your computer and use it in GitHub Desktop.
Save ellisvalentiner/3abd6563c7edf4e03fc562629df76a40 to your computer and use it in GitHub Desktop.
Basic format for Google Maps geocoder API
library(httr)
baseurl = "https://maps.googleapis.com/maps/api/geocode/json"
res <- GET(baseurl, query=list(address = "1600 Amphitheatre Parkway, Mountain View, CA", key = Sys.getenv("GOOGLE_MAPS_KEY")))
content(res)$results[[1]]$address_components[[7]]$short_name
lat = content(res)$results[[1]]$geometry$location$lat
lng = content(res)$results[[1]]$geometry$location$lng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment