Skip to content

Instantly share code, notes, and snippets.

@troy0820
Last active March 12, 2018 16:00
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 troy0820/bc31a45e4ed58c6423e8 to your computer and use it in GitHub Desktop.
Save troy0820/bc31a45e4ed58c6423e8 to your computer and use it in GitHub Desktop.
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