Use the callback URL parameter when you load the Maps API and it will not use document.write() . On a regular web page, you can do this as follows:
function initMap() { // Create the map object here as usual } function loadMapsAPI() { var script = document.createElement( 'script' ); script.src = 'http://maps.googleapis.com/maps/api/js' + '?sensor=false&callback=initMap'; document.body.appendChild( script ); }
Documentation
Example
I do not know how this will interact with the Chrome extension, but how it is done on a regular web page.
source share