var unique_interests = window.facebook_interests.filter((v, i, a) => 
a.indexOf(v) === i);
       var input = map.getCenter();
       var a =;
       var b = input.lng();
       var latlng = {lat: a, lng: b};
       window.markersGP = [];
       for(var i=0; i<unique_interests.length; i++)
       var request = {
    location: latlng,
    radius: '500',
    query: unique_interests[i]
       service = new google.maps.places.PlacesService(map);
       service.textSearch(request, function (results, status){

Whenever the callback functions are called, the for loop has executed 
completely, and the alert() always print out the last value in the array. 
Is there any way to bind the data with the function call?

You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to