0

I have this function :

var contor = 0;
function processImobs(){
  for( var i = 0; i < availableImobs.length; ++i){
        processEachImob(availableImobs[i]); 
    }
}

And in my processEachImob function i call the nearbySearch method from Google Maps:

       service = new google.maps.places.PlacesService(map);
        service.nearbySearch({ 
            location:  new google.maps.LatLng(imob[0],  imob[1]),
            radius: 500,
            type: ['pharmacy']
            },function callBack(results, status){   
            //cate tipuri de places primesc 
                markersP= []; 
                if (status == google.maps.places.PlacesServiceStatus.OK){
                    for (var i = 0; i < results.length; i++) {
                        createPharmaciesMarker(results[i]);
                    }   
                    //console.log(markersP.length + " " +imob[0]);
                    if( markersP.length !=0){
                        for(var i=0; i < markersP.length; ++i){
                            ++contor;
                            var latLng = [markersP[i].position.lat(), markersP[i].position.lng()];
                            queue.add(imob, latLng, 'pharmacy');        

                        }
                    }                   
                }
        });     

"contor" is a global variable, which i want to access from processImobs(), but its value is still 0, because it is not kept throughout the callback i guess? Is there a way to solve this?

Dalisay
  • 39
  • 5

0 Answers0