编辑:问题解决了,我正在尝试使用变量赋值,如下所示
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(‘购物商场’,‘鞋店’,‘珠宝店’,‘食品杂货店’,‘家具店’,‘电器店’,‘服装店’,'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);但它不起作用。有谁能帮我..。谢谢
解决方案:只需使用check代替tmp_types并删除正方形brackets..like此类型: check..感谢布鲁诺
发布于 2012-11-18 22:29:46
您的for循环在0退出,因为您的条件是i < 1
for( var i=0, len = check.length; i < len; i++ ) {
// your code here
}此外,根据API文档,您要调用的函数要求请求对象中的类型为:
一个数组,包含Google Places API: supported Place types列表中列出的一个或多个支持的类型。
所以只需像这样使用check对象
var request = {
location: latlng,
radius: '50000',
types: check
};更多信息here
https://stackoverflow.com/questions/13440866
复制相似问题