Hi, i'm trying to load dynamically the google maps api javascript and
i'm failed.
If i load dynamically using document.write out of window.load event,
is work fine.
But if i load dinamically in the window.load event, is fail, the page
get a error and redirect.
This is my code:
window.onload = function() {
MEGASENA.utilities.loadScript('http://maps.google.com/maps/api/js?
sensor=false', function() {
MEGASENA.googleMaps.buildMap('map_canvas', function() {
MEGASENA.googleMaps.addMarker('Ipatinga - MG -
Brasil');
MEGASENA.googleMaps.addMarker('São Paulo - SP -
Brasil');
MEGASENA.googleMaps.addMarker('Rio de Janeiro - RJ -
Brasil');
MEGASENA.googleMaps.addMarker('Barbacena - MG -
Brasil');
});
})
}
....
loadScript = function(url, callback) {
var scriptId = MEGASENA.utilities.newKey();
document.write('<' + 'script id="' + scriptId + '"
src="' + url + '"' + ' type="text/javascript"><' + '/script>');
var script = document.getElementById(scriptId);
if (script.readyState) { //ie
script.onreadystatechange = function() {
if (script.readyState == 'loaded' ||
script.readyState == 'complete') {
script.onreadystatechange = null;
if (typeof callback == 'function')
callback();
}
};
} else { //others
script.onload = function() {
if (typeof callback == 'function') callback();
};
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.