我有一个应用程序,我需要在infowindow
气泡中的数据自动更新。我检查了一下,我看到了移动标记,更新标记颜色等的方法,但没有直接更新infowindow内容。我从内容自动更新的隐藏DOM元素中提取必要的值(例如building[i][7]
),我需要infowindow的内容自动更新。谷歌地图Infowindow自动更新
这是我用来绘制infowindow
气泡的代码。
infowindow=new google.maps.InfoWindow();
for (i=0;i<buildings.length;i++){
marker=new google.maps.Marker({
position:new google.maps.LatLng(buildings[i][4],buildings[i][5]),
map:map,
shadow:shadow,
icon:greenIcon,
title:buildings[i][0]+" \n"+buildings[i][1],
zIndex:buildings[i][6]
});
}
google.maps.event.addListener(marker,'click',(function(marker,i){
return function(){
infowindow.setContent(
'<h2>'+buildings[i][0]+'</h2>'+
'<p>'+buildings[i][2]+'</p>'+
'<p>'+buildings[i][7]+'</p>'
);infowindow.open(map,marker);
}
})(marker,i));
任何帮助,非常感谢!
是否有某种事件会触发,让您知道数据已更改?你的意思是说,只要隐藏的DOM元素的数据发生变化,你就想让InfoWindow内容发生变化? – 2012-04-27 20:14:22
除了隐藏div的内容改变之外,没有任何事件会触发(是否有某种方式将其作为事件进行度量?)。 无论何时隐藏div的内容发生更改,您都希望InfoWindow内容发生更改,这是正确的。 – InterfaceGuy 2012-04-27 21:40:43