Failed to execute 'write' on 'Document' error in loading angular google map

匿名 (未验证) 提交于 2019-12-03 02:34:02

问题:

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.

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?

回答1:

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!