首先,我是JavaScript的新手。
我想在这种包含经度和纬度的数组中动态地插入变量。希望得到帮助..。
var locations = [
[ test, test1],
[ -33.923036, 151.259052],
[ -34.028249, 151.157507],
[ -33.80010128657071, 151.28747820854187],
[-33.950198, 151.259302 ]
]; 变量检验=-33.923036,变量test1 = 151.259052;
提前谢谢。
发布于 2017-04-07 06:14:10
试试这个-
必须使用push方法将对象插入到数组中。
var test = -33.923036; var test1 = 151.259052;
var locations = [
[ -33.923036, 151.259052],
[ -34.028249, 151.157507],
[ -33.80010128657071, 151.28747820854187],
[-33.950198, 151.259302 ]
];
locations.push([test, test1])
console.log(locations)
发布于 2017-04-07 06:11:36
可以使用push方法在数组中添加新元素。
var newValues = [test,test1];
locations.push(newValues);发布于 2017-04-07 06:11:52
试试这个locations.push([variable_name_1,variable_name_2])
https://stackoverflow.com/questions/43270831
复制相似问题