1

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
  • 1
    Maybe you should try the documentation directly. doc. And here's a similar problem: Link. Hope this can be a reference to you. Commented May 26, 2015 at 18:16

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.