Here's the code that I'm using:
var infoWindow = new InfoBubble({content: request.responseText,
maxWidth: 1000, position: latLng, arrowSize: 0, maxHeight:
600});
infoWindow.open(map);
google.maps.event.addListener(infoWindow, "domready", function()
{load_rotator();});
Thanks in advance!
-- Geoff
It might be that the 'domready' event fires BEFORE your next line of
code which adds an event listener for that event.
(The event happens before you listen for it).
Try adding the domready event listener before opening the InfoBubble:
var infoWindow = new InfoBubble({content: request.responseText,
maxWidth: 1000, position: latLng, arrowSize: 0, maxHeight: 600});
google.maps.event.addListener(infoWindow, "domready", function()
{load_rotator();});
infoWindow.open(map);
Martin.
On Nov 23, 4:03 pm, Geoff Schultz <geoffrey.w.schu...@gmail.com>
wrote:
Thanks for the suggestion, but I tried that and there was no
difference.
-- Geoff
I'm sure infobubble fires domready events. Show us your demo?
-- Geoff
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#mapdiv { height: 100% }
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?
sensor=false"></script>
<script type="text/javascript">
var script = '<script type="text/javascript" src="http://google-
maps-' +
'utility-library-v3.googlecode.com/svn/trunk/infobubble/src/
infobubble';
if (document.location.search.indexOf('compiled') !== -1) {
script += '-compiled';
}
script += '.js"><' + '/script>';
document.write(script);
function display_map()
{
var latLng = new google.maps.LatLng(42, -71);
var myOptions = {zoom: 8, center: latLng, mapTypeId:
google.maps.MapTypeId.ROADMAP};
map = new google.maps.Map(document.getElementById("mapdiv"),
myOptions);
var responseText = "This is my info";
// var infoWindow = new google.maps.InfoWindow({content:
responseText,
// maxWidth: 1000, position: latLng, boxStyle: {width: "1000px"}});
var infoWindow = new InfoBubble({content: responseText,
maxWidth: 1000, position: latLng, arrowSize: 0, maxHeight:
600});
google.maps.event.addListener(infoWindow, "domready", function()
{load_rotator();});
infoWindow.open(map);
}
function load_rotator()
{
alert("Executing load_rotator");
}
</script>
</head>
<body onLoad="display_map()">
<div id="mapdiv" style="width:100%; height:100%"></div>
</body>
</html>
Stepping through the code with Firebug, the domReady event is fired by
InfoBubble before your listener is created, in my browser.
> and here's the code.
No need with a good link :)
> var infoWindow = new InfoBubble({content: responseText, ...
This creates the InfoBubble and populates it. Unlike the standard
Infowindow, it's not done asynchronously so 'domready' was fired when
complete, before returning to your script.
> google.maps.event.addListener(infoWindow, "domready", ...
Too late, the event has already happened
> Anyhow, what I finally figured out was that I needed to set the
content AFTER I have created the listener.
That's fine, it is just one of the ways to add the listener before
setting content.
Nope, I just set breakpoints in Firebug to see the sequence
> http://www.geoffschultz.org/Test/infobubble_2.htmlutilizes an infoBubble
I think the infobubble 'domready' event is optimistic ; infobubble has
issued the commands to the browser to build the dom elements, but at
the time the browser is busy building map stuff and hasn't got around
to it by the time the infobubble code fires 'domready' in inline code.
In Firefox, there isn't even a map in the DOM let alone an infobubble
when your load_rotator() is called.
The standard infowindow runs asynchronously, and so gets queued behind
all the other map workings before its 'domready' is called.
I believe there is a trick you can do with javascript setTimeout to
put a task on the back of the browsers queue, use setTimeout to call
your load_rotator() with a zero timeout.
If this is the case, it looks like a worthwhile enhancement to the
infobubble library?
Yep, infobubble's 'domready' event is still optimistic, it fires
before the browser has had time to render the DOM, so the DOM elements
are still not available to your load_rotator() yet.
The setTimeout suggestion stands.
setTimeout ('doMyFunction(blah)', 0);
Looks like a zero delay, but would should happen is that a new task is
appended to the browser's work queue after a zero delay. I believe/
hope that should then be run after the browser's finished building
previously setup DOM elements.
I think you are right that infobubble could be improved, the author
Luke may read this ?