Loading gmaps api dynamically from a chrome extension content script

193 views
Skip to first unread message

Andrey

unread,
Dec 15, 2011, 8:14:01 PM12/15/11
to google-map...@googlegroups.com
Hi there!

i'm trying to load gmap scripts dynamically form via chrome extension. I use the following code and call it from extension's content script:

    var script = document.createElement("script");
    script.type = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(script);

a very popular solution as you can see )

However, this only adds a corresponding tag into the head section, but doesn't execute the script.
e.g. main.js is not loaded.

Of coгrse, any further attempts to instantiate a map fail.. 

Beforehand thanks for any suggestions!
Andrey

Rossko

unread,
Dec 16, 2011, 5:00:29 AM12/16/11
to Google Maps JavaScript API v3
Have you seen the recommended solution
http://code.google.com/apis/maps/documentation/javascript/basics.html#Async
note that including the 'callback' parameter modifies the behaviour
Reply all
Reply to author
Forward
Message has been deleted
0 new messages