Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将google地图api合并到chrome扩展/document.write的替代方案中_Javascript_Google Maps_Google Maps Api 3_Google Chrome Extension - Fatal编程技术网

Javascript 将google地图api合并到chrome扩展/document.write的替代方案中

Javascript 将google地图api合并到chrome扩展/document.write的替代方案中,javascript,google-maps,google-maps-api-3,google-chrome-extension,Javascript,Google Maps,Google Maps Api 3,Google Chrome Extension,我正在尝试将谷歌地图api合并到我的chrome扩展中。但是,我发现清单版本2不允许document.write。有什么办法可以解决这个问题吗?在加载Maps API时使用回调URL参数,它不会使用document.write()。在普通网页中,您可以这样做: function initMap() { // Create the map object here as usual } function loadMapsAPI() { var script = document.c

我正在尝试将谷歌地图api合并到我的chrome扩展中。但是,我发现清单版本2不允许
document.write
。有什么办法可以解决这个问题吗?

在加载Maps API时使用
回调
URL参数,它不会使用
document.write()
。在普通网页中,您可以这样做:

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 );
}

我不知道这将如何与Chrome扩展交互,但这就是它在常规网页中的实现方式