Thursday, December 20, 2007

Load map script dynamically

I posted a topic in google maps api group asking how to load a map script dynamically. Thanks to igloo that response this to my question. The Maps API can be loaded dynamically by creating script tag and append it to the head section of the html page. You can call your own function to run when the loading of the map is finished. Here is a sample code.

function loadScript(callbackName) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "" + callbackName;

You can test here:

No comments:

Subscribe in a Reader