[thelist] Google Map - onload & onunload without access to <body>

Jono Jono at charlestonwebsolutions.com
Mon Aug 10 19:02:59 CDT 2009


I need to get the following implemented without having access to the 
<body> tag:
...
<script src="googleMapApiKeyHere" type="text/javascript"></script>
<script src="countryXml.js" type="text/javascript"></script>
<script type="text/javascript">

    var map, exml;
    function initialize() {
   
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(22.350075806124853, 83.056640625), 4);
        map.setMapType(G_PHYSICAL_MAP);
       
        map.disableDragging();
        map.disableDoubleClickZoom();
       
           exml = new EGeoXml("exml", map, "countryName.kml", 
{nozoom:true});
        exml.parse();
      }
    }
</script>
</head>
...
<body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas">
    </div>
  </body>
</html>

Mostly, I need a way to do body onload="initialize()" 
onunload="GUnload()" without having access to the body.  This is for a 
CMS that has jQuery support baked in, but there is also a ton of other 
scripts that I need to not interfere with.

I am a JS hack on a good day, can someone please suggest a solution that 
I can try?  I will more or less be doing this, with in a designated 
content area within the apge:

<script src="googleMapApiKeyHere" type="text/javascript"></script>
<script src="countryXml.js" type="text/javascript"></script>
<script type="text/javascript">

    var map, exml;
    function initialize() {
   
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(22.350075806124853, 83.056640625), 4);
        map.setMapType(G_PHYSICAL_MAP);
       
        map.disableDragging();
        map.disableDoubleClickZoom();
       
           exml = new EGeoXml("exml", map, "countryName.kml", 
{nozoom:true});
        exml.parse();
      }
    }
</script>
<!-- on load work around here -->
<div id="map_canvas">
</div>

Thanks!



More information about the thelist mailing list