Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google.charts not loaded if google.maps already loaded #42

Closed
mark-roy opened this issue Dec 17, 2018 · 1 comment
Closed

google.charts not loaded if google.maps already loaded #42

mark-roy opened this issue Dec 17, 2018 · 1 comment
Labels
bug Something isn't working

Comments

@mark-roy
Copy link

I'm using both Angular Google Maps https://angular-maps.com/ and angular-google-charts in my app. However, if google.maps gets loaded prior to google.charts, I get this error:

core.js:14597 ERROR TypeError: Cannot read property 'load' of undefined
at Observable._subscribe (angular-google-charts.js:87)

which is this line:
google.charts.load('45.2', config);

I believe that the source of the issue is here:

    Object.defineProperty(ScriptLoaderService.prototype, "doneLoading", {
        get: /**
         * @return {?}
         */
        function () {
            if (typeof (google) !== 'undefined') {
                return true;
            }
            return false;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScriptLoaderService.prototype, "isLoading", {
        get: /**
         * @return {?}
         */
        function () {
            var _this = this;
            if (typeof (google) === 'undefined') {
                /** @type {?} */
                var pageScripts = Array.from(document.getElementsByTagName('script'));
                return pageScripts.findIndex(function (script) { return script.src === _this.scriptSource; }) >= 0;
            }
            return false;
        },
        enumerable: true,
        configurable: true
    });

where the test if (typeof (google) !== 'undefined') fails when google.maps is already loaded, which short-circuits the loading of google.charts.

My chart works fine if I avoid displaying a map prior to a chart. Is there a workaround?

@FERNman FERNman added the bug Something isn't working label Dec 17, 2018
@antoinevulcain
Copy link

I have the same problem you find a solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants