Arrays Google将API 3 LatLng值映射为一个数组

Arrays Google将API 3 LatLng值映射为一个数组,arrays,syntax,google-maps-api-3,polygon,Arrays,Syntax,Google Maps Api 3,Polygon,底线是:如何使用数组从800 lat/lng值创建多边形? 我试图将LatLng值作为数组元素传递给 var paths = new Array(); var l = coords.length; for (coords = 0; coords <= l; coords++){ paths[x] = new google.maps.LatLng( coords[x][0], coords[x][1]); } 我尝试了耗时的“警报调试”,似乎使用的值还可以,但不知何故,循环和数组失

底线是:如何使用数组从800 lat/lng值创建多边形?

我试图将LatLng值作为数组元素传递给

var paths = new Array();
var l = coords.length;
for (coords = 0; coords <= l; coords++){
    paths[x] = new google.maps.LatLng( coords[x][0], coords[x][1]);
}
我尝试了耗时的“警报调试”,似乎使用的值还可以,但不知何故,循环和数组失败了。即使我得到了正确的数组,我也无法使用它们为地图创建多边形

如果我使用以下语法

var polygon_coords = [
new google.maps.LatLng(),
new google.maps.LatLng(),
....
];

它起作用了。但是因为我有800行这样的代码,所以有点太多了。如果我得到了正确的数组,我是否应该使用某种侦听器,以便仅在所有LatLng函数就绪后渲染贴图?

Replace
for(coords=0;coords@user1113426不,等等,刚刚意识到你能提供
coords
数组的结构吗?@user1113426是的,它成功了!谢谢!我最近做了太多的工作,而且开始太多了,甚至看不到明显的东西。再次感谢!
var polygon_coords = [
new google.maps.LatLng(),
new google.maps.LatLng(),
....
];