Reputation: 99
I am trying to incorporate google maps api into my chrome extension. However, I found out that manifest version 2 does not allow document.write
. Is there any way around this?
Upvotes: 4
Views: 938
Reputation: 28870
Use the callback
URL parameter when you load the Maps API, and it won't use document.write()
. In a normal web page you might do it like this:
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 );
}
I don't know how this would interact with a Chrome extension, but that's how it's done in a regular web page.
Upvotes: 3