0

我有这个变量,我想动态添加其他变量,因为我从 XML 文件中读取了 latlng、名称等。

var stationMapList = [
    {"latlng":[41.38506,2.17340],name:"Barcelona", pin:'img/pin_2.png', id:'address0', tab:'tab1-button'},
    {"latlng":[41.11902,1.24521],name:"Tarragona", pin:'img/pin.png', id:'address1', tab:'tab1-button'},
]

我想将这些添加到 stationMapList,我该怎么做?

{"latlng":[40.41678,-3.70379],name:"Madrid", pin:'img/pin_2.png', id:'address2' ,tab:'tab1-button'},
{"latlng":[37.99233,-1.13046],name:"Murcia", pin:'img/pin.png', id:'address3' ,tab:'tab1-button'},
{"latlng":[39.46991,-0.37629],name:"Valencia", pin:'img/pin.png', id:'address4' ,tab:'tab1-button'}
4

1 回答 1

0

根据提供的有限信息,这是我想出的可能解决方案

var stationMapList = [
    {"latlng":[41.38506,2.17340],name:"Barcelona", pin:'img/pin_2.png', id:'address0', tab:'tab1-button'},
    {"latlng":[41.11902,1.24521],name:"Tarragona", pin:'img/pin.png', id:'address1', tab:'tab1-button'},
    {"latlng":[40.41678,-3.70379],name:"Madrid", pin:'img/pin_2.png', id:'address2' ,tab:'tab1-button'},
    {"latlng":[37.99233,-1.13046],name:"Murcia", pin:'img/pin.png', id:'address3' ,tab:'tab1-button'},
    {"latlng":[39.46991,-0.37629],name:"Valencia", pin:'img/pin.png', id:'address4' ,tab:'tab1-button'}
]
于 2013-09-18T05:47:12.827 回答