【发布时间】:2016-10-07 08:46:56
【问题描述】:
更新: 我正在尝试以数组形式发送具有多种类型的 Google Places API 请求。但是,我无法传递带有从复选框值添加的位置列表的数组变量。任何帮助将不胜感激。
这行得通:
var poi = new google.maps.LatLng(lt,lg);
var gplaces = ['shopping_mall','bus_station'];
var request = {
location: poi,
radius: '500',
types: gplaces
};
但不是这个:
var poi = new google.maps.LatLng(lt,lg);
var gplaces = []
$('#chklist:checked').each(function() {
gplaces.push($(this).val());
});
var request = {
location: poi,
radius: '500',
types: gplaces
};
在第二种情况下,API 将返回一个默认的地点列表(好像我根本没有传递任何类型)。
我尝试了一个 console.log(gplaces),它包含 ['shopping_mall','bus_station']。
我还检查了 console.log(request),我可以在请求中看到列表的各个元素。
有人可以帮我解决这个问题吗?
【问题讨论】:
-
你能粘贴更多代码吗?对我来说很好用
-
@weigreen 我现在已经更新了这个问题。请检查。
-
你能做一个小提琴吗?
标签: google-maps google-places-api