Edit: Problem solved
I am trying to assign types using variable like this
check = [];
if($("#transport").attr("checked"))
check.push('airport','bus_station','train_station','taxi_stand','travel_agency');
if($("#bars").attr("checked"))
check.push('bar','restaurant');
if($("#tourist").attr("checked"))
check.push('art_gallery','campground','museum','aquarium','zoo','library','amusement_park','park');
if($("#shopping").attr("checked"))
check.push(‘shopping_mall’,’shoe_store’,’jewelry_store’,’grocery_or_supermarket’,’furniture_store’,’electronics_store’,’clothing_store’,’book_store’);
var tmp_types = "";
for(i=0;i<1;i++)
{
tmp_types += '"'+check[i]+'"';
}
var request = {
location: latlng,
radius: '50000',
types: [ tmp_types ]
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
but its not working… can anybody help me… thanks
solution: just use check in place of tmp_types and remove square brackets..like this types: check.. thanks to Bruno
Your for loop exits at 0 because your condition is
i < 1Also according to the API documentation the function you are calling expects types in the request object to be:
So just use the check object like so
More info here