Last active
December 16, 2015 15:22
-
-
Save watagashi/6daf435b756e2451b4f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var fs = require('fs'); | |
var program = require('commander'); | |
var GoogleMapsAPI = require('googlemaps'); | |
var gapiConf = { | |
key: 'google API key', | |
secure: true | |
}; | |
var gmAPI = new GoogleMapsAPI(gapiConf); | |
var geocodeParams = { | |
language: 'ja', | |
region: 'ja' | |
}; | |
var data = JSON.parse(fs.readFileSync('data.json')); | |
var outputFile = 'data.json.out'; | |
for(var i = 0; i < data.length; i++) { | |
(function(i) { | |
var address = data[i].address; | |
geocodeParams.address = address; | |
gmAPI.geocode(geocodeParams, function(err, result){ | |
if(err) { | |
console.error('[' + i + ']', 'Parse failed: ', address); | |
console.log(err); | |
} else { | |
var location = result.results[0].geometry.location; | |
console.log('[' + i + ']',location); | |
} | |
}); | |
})(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment