Last active
March 12, 2018 16:00
-
-
Save troy0820/bc31a45e4ed58c6423e8 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
var getzips = function(lat, lng) { | |
return new Promise((resolve, reject) => { | |
geocode.reverseGeocode(lat, lng, (err, data) => { | |
if (err) { reject(err); } | |
var result = data.results[0].address_components[6].short_name; | |
resolve(result); | |
}); | |
}); | |
}; | |
Promise.all(lat_lng.lat.map((_,index) => { | |
return getzips(lat_lng.lat[index],lat_lng.lng[index]); | |
}) | |
).then((data) => { | |
var zips = _.union(data); | |
console.log('These are the zip codes',zips); | |
}); | |
}) | |
.finally(() => { | |
console.log('We are finally done here'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment