无法执行“写”上的“文件”错误加载角谷歌地图 [英] Failed to execute 'write' on 'Document' error in loading angular google map
问题描述
我使用在Web开发项目angularjs并采用了棱角分明谷歌地图
API向我推荐添加谷歌地图到我的项目。
这是非常有用的API,但是当我使用这个加载它在我的项目快速启动它崩溃了一段时间,并抛出此异常对我说:
i am using angularjs in a web development project and using Angular Google Maps api was recommended to me for adding google map to my project. it was very useful api but when i load it in my project using this quick start it crash some time and throw this exception to me:
未能在文档执行写:是不是可以写
成从异步加载外部脚本,除非文档
它明确地打开。
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
和一段时间它的工作不错。我在谷歌搜索,现在我知道这个问题是因为在加载页面加载谷歌地图。任何人都可以帮我找到一个解决方案异步加载后加载地图的部分HTML表单?
and some time it work nice. i searched in google and now i know this problem is because of loading google map after loading page. anyone can help me to find a solution to load map to partial html form after loading asynchronously?
推荐答案
指定&安培;回调= someWindowFunction
在您的API请求和文件撰写
将不会被调用。
Specify &callback=someWindowFunction
in your api request and document.write
won't get called
var _this = this;
window["googleMapsLoad"] = function () {
_this.googleMapsLoaded = true;
if (_this.initialized) {
_this.reportReady();
_this.createMap();
}
};
this.initialize = function (reportReady) {
this._super(false);
if (this.googleMapsLoaded) {
this.reportReady();
this.createMap();
}
};
var script = document.createElement("script");
script.src = "//maps.googleapis.com/maps/api/js?callback=googleMapsLoad";
document.head.appendChild(script);
这篇关于无法执行“写”上的“文件”错误加载角谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!