javascript - 在多维数组上添加一个值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18627318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javascript - add a value on multidimensional array
提问by Dustine Tolete
I am developing a website with bing map. I've almost done it, but i want to have the pin clustering functionalitty. Then i got this code from the internet:
我正在开发一个带有 bing 地图的网站。我几乎已经完成了,但我想拥有 pin 聚类功能。然后我从互联网上得到了这个代码:
var data = [
{ "latitude": 59.441193, "longitude": 24.729494 },
{ "latitude": 59.432365, "longitude": 24.742992 },
{ "latitude": 59.431602, "longitude": 24.757563 },
{ "latitude": 59.437843, "longitude": 24.765759 },
{ "latitude": 59.439644, "longitude": 24.779041 },
{ "latitude": 59.434776, "longitude": 24.756681 }
];
I can get the latitude and longitude of every pushpin on my map, but i don't know how to add the latitude and longitude on this array. Can anyone help me?
我可以获得地图上每个图钉的纬度和经度,但我不知道如何在这个数组上添加纬度和经度。谁能帮我?
回答by David Byttow
data.push({"latitude": lat, "longitude": lng});