Error loading asynchronous Google Maps in IE

I searched for this error everywhere and did not find anything that works. Here is the code:

MapsLoader.prototype._setup = function () {
    var promise = new RSVP.Promise(function (resolve) {

        // Callback for Google Maps that resolves the promise
        window.gmapsLoaded = function () {
            console.log('[Maps Loader] Loaded');
            resolve();
        };

        console.log('[Maps Loader] Loading...');

            // Create a URL with the API key pointing to the gmapsLoaded callback
        var mapsURL = 'https://maps.googleapis.com/maps/api/js?key=' + config.googleMaps.APIKey + '&sensor=false&callback=gmapsLoaded',

            // Create script object
            script = $('<script />').attr('src', mapsURL);

        $('head').append(script);
    });

    // Remove the gmapsLoaded function from global scope
    promise.then(function () {
        window.gmapsLoaded = undefined;
    });

    // Return the promise
    return promise;
};

This is the part of the module MapsLoaderthat is simply added to the Google Maps script in head(only when necessary), awaits the Google Maps download callback, and then resolves the promise (at this point the file that uses it may start to do things).

Works well in Safari, Chrome, Firefox, and IE10. However, in IE 8 and 9, I get an error:

  • Object doesn't support property or method 'Load' (IE9)
  • Object doesn't support property or method (IE8)

What comes from line 55 of the main.jsGoogle Maps file :

k.google.maps.Load(...)

This occurs after the “Load Loader Loaded” log message, so the callback is executed and the page continues to load normally, except that the Google Maps area is empty.

(.. IE Developer Tools), , , - .

, Google Maps head , IE ( , google MapsLoaded). , , .


: RequireJS .

, :

  • async=2 URL- Google ( )
  • body head ( API Google)
  • $.ready

+4
2

$.getScript(mapsURL) (.. AJAX) script head, , .

, , .

+3

<script src="https://cdn.polyfill.io/v3/polyfill.min.js"></script> . - polyfill .

0

Source: https://habr.com/ru/post/1530238/


All Articles