我有像
这样的json数据 {"ID":1,"SensorID":1,"SensorName":"Sensor1","Lattitude":32.4,"Longitude":70.02,"Battery":"100 "},
{"ID":2,"SensorID":2,"SensorName":"Sensor2","Lattitude":32.1,"Longitude":70.12,"Battery":"70 "}
这是来自我的网络工作者的随机数据。 我想在java脚本中创建对象列表,并将这些值传递给javascript对象。 之后,我想在谷歌地图上从这些对象制作标记,并在标记点击,我想查看该标记对象的相关信息。
答案 0 :(得分:1)
试试这个,
<强> JS:强>
var o =[{"ID":1,"SensorID":1,"SensorName":"Sensor1","Lattitude":32.4,"Longitude":70.02,"Battery":"100 "},
{"ID":2,"SensorID":2,"SensorName":"Sensor2","Lattitude":32.1,"Longitude":70.12,"Battery":"70 "}];
var arr = $.map(o, function(el) { return el; });
console.log(arr);
<强> FIDDLE 强>