更改内容infowindow地图v3 [英] change content infowindow maps v3
问题描述
我试图改变显示在作为infowindow内容的DIV内的内容。我已经能够在infowindow中将内容从Hello更改为YO。问题是当我关闭infowindow并重新打开它时,更新的内容将恢复为原始状态。下面是我的代码:
I am trying to make it possible to change the content that shows up inside a DIV that is the content of an infowindow. I have been able to change the content from Hello to YO inside the infowindow. The problem is when I close the infowindow and reopen it the updated content reverts back to the original. Below is my code:
google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
if (event.type == google.maps.drawing.OverlayType.MARKER) {
//event.overlay.setTitle("Hello");
var infowindow = new google.maps.InfoWindow({
content: '<div id="content" onmouseover="updateContent()">Hello</div>',
maxWidth: 10
});
google.maps.event.addListener(event.overlay, 'click', function() {
infowindow.open(map, event.overlay);
});
}
});
function updateContent() {
document.getElementById('content').innerHTML = "Yo";
}
我基本上想创建一个默认信息窗口并允许用户输入他们的将广告放在页面后自己的文字...
I basically want to create a default info window and allow the user to input their own text after they place the marke on the page...
推荐答案
你必须通过setContentHTML方法设置内容
you have to set the content through setContentHTML method
var infowindow ;
google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
if (event.type == google.maps.drawing.OverlayType.MARKER) {
//event.overlay.setTitle("Hello");
infowindow = new google.maps.InfoWindow({
content: '<div id="content" onmouseover="updateContent()">Hello</div>',
maxWidth: 10
});
google.maps.event.addListener(event.overlay,'click',function()
infowindow.open(map,event.overlay);
});
}});
function updateContent(){
infowindow.setContent("YO");
}
这篇关于更改内容infowindow地图v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!