Hallo Linuchs,
einfache Lösung: GM-API normal mit <script src=... einbinden.
Wenn es unbedingt dynamich sein soll, hier ein Auszug aus meinem GPX-Viewer:
JB.LoadScript = function(url,callback) {
var scr = document.createElement('script');
scr.type = "text/javascript";
scr.async = "async";
if(typeof(callback)=="function") {
scr.onloadDone = false;
scr.onload = function() {
if ( !scr.onloadDone ) {
scr.onloadDone = true;
JB.Debug_Info(url,"loaded",false);
callback();
}
};
scr.onreadystatechange = function() {
if ( ( "loaded" === scr.readyState || "complete" === scr.readyState ) && !scr.onloadDone ) {
scr.onloadDone = true;
JB.Debug_Info(url,"ready",false);
callback();
}
}
}
scr.onerror = function() {
JB.Debug_Info(url,"Konnte nicht geladen werden.",false);
}
scr.src = url;
document.getElementsByTagName('head')[0].appendChild(scr);
} // LoadScript
JB.gmcb = function() {
JB.Scripte.googlemaps = 2;
} // gmcb
JB.LoadScript("http://maps.google.com/maps/api/js?sensor=false&callback=JB.gmcb", function() {});
JB.gmcb wird aufgerufen, wenn die API vollständig geladen ist. Die Callbackfunktion meines JS-Loaders wird hier nicht benötigt, daher leere Funktion.
Gruß, Jürgen