How to get an element ID from an InfoBox

47 views
Skip to first unread message

GeoffSchultz

unread,
Dec 3, 2011, 9:13:08 AM12/3/11
to google-maps-utility-library-v3
If I create an InfoWindow, I can use getElementById to inspect the
status of things like a checkbox, but if I use an InfoBox, the element
comes back as undefined. How do I do this?

A code sample showing this is at http://www.geoffschultz.org/Test/infowindow.html
Click on the map to create the InfoBox and when you close it, it tries
to check the checkbox status.

and here's the section in question:

function clicked(event)
{
var responseText = '<form><input type="checkbox" id="dns"/>Do not
show this message again.</form>';
var pos = event.latLng;
// var infoWindow = new google.maps.InfoWindow({maxWidth: 1000,
position: pos, content: responseText});
var infoWindow = new InfoBox({maxWidth: 1000, position: pos, content:
responseText});
infoWindow.open(map);
google.maps.event.addListener(infoWindow, "closeclick", function()
{check();});
}

function check()
{
if (document.getElementById("dns").checked)
{alert("yes");}
}

Gary Little

unread,
Dec 9, 2011, 7:19:22 PM12/9/11
to google-maps-utility-library-v3
InfoBox triggers the closeclick event after closing the InfoBox, so I
suspect all the DOM elements in the box are gone by the time your
handler takes over.

Try changing the order in the source code (in
InfoBox.prototype.getCloseClickHandler_) and if you get the desired
behavior I can make the same change to the official code and tag a new
release. Just move "me.close() to after google.maps.event.trigger(me,
"closeclick");

Gary

On Dec 3, 6:13 am, GeoffSchultz <geoffrey.w.schu...@gmail.com> wrote:
> If I create an InfoWindow, I can use getElementById to inspect the
> status of things like a checkbox, but if I use an InfoBox, the element
> comes back as undefined.  How do I do this?
>

> A code sample showing this is athttp://www.geoffschultz.org/Test/infowindow.html

Gary Little

unread,
Dec 11, 2011, 11:32:33 AM12/11/11
to google-maps-utility-library-v3
Try the new trunk version (1.1.10) at
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/

It should fix your problem.

Gary

Reply all
Reply to author
Forward
0 new messages