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

后端 未结 1 711
無奈伤痛
無奈伤痛 2021-01-23 17:35

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

相关标签:
1条回答
  • 2021-01-23 18:18

    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);
    
    0 讨论(0)
提交回复
热议问题