Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
129
rated 0 times [  130] [ 1]  / answers: 1 / hits: 25941  / 12 Years ago, wed, september 5, 2012, 12:00:00

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...


More From » maps

 Answers
24

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);
}

[#83227] Tuesday, September 4, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cadendericki

Total Points: 482
Total Questions: 109
Total Answers: 103

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
cadendericki questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Wed, Jul 8, 20, 00:00, 4 Years ago
Thu, May 14, 20, 00:00, 4 Years ago
;