Beispiel #1
0
 _.keys(countryMapping.location).forEach(function(country) {
     var deferredLoop = Q.defer();
     geolocator.locate(countryMapping.location[country], country)
         .then(function(resp) {
             result[country] = resp.body;
             deferredLoop.resolve();
         })
         .catch(deferredLoop.reject);
     promises.push(deferredLoop.promise);
 });
Beispiel #2
0
 regioni.forEach(function(regione) {
     var deferredLoop = Q.defer();
     geolocator.locate(regione + ', Italy')
         .then(function(resp) {
             result.regions.push({
                 region: regione,
                 details: resp.body
             });
             deferredLoop.resolve();
         })
         .catch(deferredLoop.reject);
     promises.push(deferredLoop.promise);
 });
Beispiel #3
0
 districts.forEach(function(district) {
     var deferredLoop = Q.defer();
     geolocator.locate(district + ', ' + countryMapping.location[country], country)
         .then(function(resp) {
             result.districts.push({
                 district: district,
                 details: resp.body
             });
             deferredLoop.resolve();
         })
         .catch(deferredLoop.reject);
     promises.push(deferredLoop.promise);
 });
Beispiel #4
0
 _.keys(locationCache).forEach(function (location, i) {
     if (locationCache[location].length == 0) {
         var deferredLoop = Q.defer();
         geolocator.locate(location, country)
             .then(function (resp) {
                 locationCache[location] = resp.body.results;
                 deferredLoop.resolve(location);
             })
             .catch(function (err) {
                 deferredLoop.reject(err);
             });
         promises.push(deferredLoop.promise);
     } else {
         console.log('Location already acquired for ' + location + ' in position ' + i);
     }
 });