你有一个浮点数组。您想要的示例将正常工作,您可以在创建数组文字时使用变量。有几种方法可以给这只猫剥皮,这里有几种:
var var1, var2, var3, etc;
var1 = [52.36889, 4.91501];
var2 = [52.29714, 4.87038];
var3 = [52.30806, 5.04616];
etc = [52.46772, 4.82849];
//adding the arrays using literal notation
var coordinates = [var1, var2, var3, etc];
//adding the arrays to a new array condensed
var coordinates = new Array(var1,var2,var3,etc);
//adding the arrays to a new array via push
var coordinates = [];
coordinates.push(var1);
coordinates.push(var2);
coordinates.push(var3);
coordinates.push(etc);
//adding the arrays to a new array via index
var coordinates = [];
coordinates[0] = var1;
coordinates[1] = var2;
coordinates[2] = var3;
coordinates[3] = etc;
var peil = new L.Polygon(coordinates);