Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getResults(makers) {
  2.     const chain = makers.map(latLong => getGeocodeData(latLong))
  3.  
  4.     Promise.all(chain)
  5.         .then(results => {
  6.             console.log('results', results)
  7.             //AQUI VOCÊ FAZ O .MAP
  8.         })
  9.         .reject(error => {
  10.             console.log('error', error)
  11.         })
  12. }
  13.  
  14. function getGeocodeData(latLong) {
  15.     const geocoder = new google.maps.Geocoder()
  16.  
  17.     return new Promise((resolve, reject) => {
  18.  
  19.         geocoder.geocode({ 'location': latLong }, (result, status) => {
  20.             // console.log(results, status)
  21.             if (status !== 'OK') {
  22.                 reject()
  23.             }
  24.             else {
  25.                 resolve(result)
  26.             }
  27.         })
  28.  
  29.     })
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement