Skip to content

Instantly share code, notes, and snippets.

@rankun203
Last active April 30, 2016 03:10
Show Gist options
  • Save rankun203/b41ebaf95a5764938590bb743be714a1 to your computer and use it in GitHub Desktop.
Save rankun203/b41ebaf95a5764938590bb743be714a1 to your computer and use it in GitHub Desktop.
Convert address to geocode
// HTTP request
const http = require('https');
const api = 'https://maps.googleapis.com/maps/api/geocode/json?address=%s',
address = '5101 ASHLEY PHOSPHATE RD STE 145 N CHARLESTON SC 29418-2843',
url = api.replace('%s', address);
http.get(url, res => {
res.on('data', d => {
console.log('' + d);
});
}).on('error', e => {
console.error(e);
});
{
"results": [
{
"address_components": [
{...}
{
"long_name" : "5101",
"short_name": "5101",
"types" : ["street_number"]
},
{
"long_name" : "Ashley Phosphate Road",
"short_name": "Ashley Phosphate Rd",
"types" : ["route"]
}
{...}
],
"formatted_address" : "5101 Ashley Phosphate Rd #145, North Charleston, SC 29418, USA",
"geometry" : {
"location" : {
"lat": 32.9147643,
"lng": -80.1021227
}
},
"partial_match" : true,
"place_id" : "Ej41MTAxIEFzaGxleSBQaG9zcGhhdGUgUmQgIzE0NSwgTm9ydGggQ2hhcmxlc3RvbiwgU0MgMjk0MTgsIFVTQQ",
"types" : ["subpremise"]
}
],
"status" : "OK"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment