I keep getting a GMap2 is undefined within my code:
////////
<html>
<head>
<script
src="
http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAUFhArcoq..."
type="text/javascript"></script>
<script type="text/javascript">
function aaa()
{
var newwin =
window.open('','','scrollbars=no,menubar=no,height=600,width=800,resizable= yes,toolbar=no,location=no,status=no');
newwin.document.write('<html><head><script
src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAUFhArcoq..."
type="text/javascript"><'+'/'+'script></head><body
onload="setInterval(\'alert(typeof(GMap2))\',1000);"></body></html>');
newwin.document.close();
}
</script>
</head>
<body onload ="alert('Main Window GMAP2: '+GMap2);">
<input type=button onclick="aaa()">
</body>
</html>
//////////
The way it works is the main window makes the standard JS script call
for Google Maps. Once the page has loaded the onload event is fired to
present the state of GMap2. It is defined successfully.
Now when i click the button on the page, it opens a new window and uses
document.write to write a new <script> tag to call google maps for the
new window. This is where the error occurs. Once the new window's
onload event fires GMap2 is now undefined and remains that way. On
inspection of the HTTP requests being made between both windows I
notice the main window makes an additional call to:
http://maps.google.com/mapfiles/maps2.50a.api.js
which the popup window never does. Both windows do make a successful
call the the <script src> though.
I am using IE6 under Windows XP. I am using a valid API and as you can
see v=2. I suspect Javascript is doing something odd here but would
like a javascript fix as opposed to loading a seperate .html file.
Thanks