我有一个如下的数据数组,可以通过点击按钮在谷歌地图上显示:
var locations = [
[50.6343356475971,-9.53181026267496,"small_red","AGH","AGH1","GAS25"],
[40.2185001907869,0.928586419184371,"meassle_grey","BES1","BES","GAS23"],
[52.1400374749101,-7.50501915638024,"small_blue","DUB1","DUB","GAS24"],
为了定义每个类的图标,我尝试了以下操作但没有成功:
function selectIcon(locations) {
for (var i = 0; i < locations.length; i++) { //Loop trough List of Data
if (locations[i][2] == "small_red") {
iconIMG = new google.maps.MarkerImage("Link to the iconAAA.png");
if (locations[i][2] == "small_blue") {
iconIMG = new google.maps.MarkerImage("Link to the iconBBB.png");
};
现在的问题是,对于所有 3 个位置,始终为所有标记显示“iconBBB.png”。