Guest User

Untitled

a guest
Jan 13th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. addSpotsMarkers() {
  2. let promises_array:Array<any> = [];
  3. let geocoder = new google.maps.Geocoder();
  4. this.spotsProvider.getSpots().subscribe((spots: Spot[]) => {
  5. this.spots = spots;
  6. this.spots.forEach((spot: Spot) => {
  7. promises_array.push(new Promise((resolve, reject) => {
  8. geocoder.geocode( { 'address': spot.address + ', ' + spot.city}, function(results, status) {
  9. console.log('results: ', results);
  10. console.log('status', status);
  11. if (status == google.maps.GeocoderStatus.OK) {
  12. resolve(results);
  13.  
  14. } else {
  15. console.error(status);
  16.  
  17. }
  18. });
  19. }));
  20. });
  21. });
  22.  
  23. return Promise.all(promises_array);
  24. }
Add Comment
Please, Sign In to add comment