Google Maps API 在 IE11 中抱怨 polyfill Array.from()

And*_*wby 5 google-maps-api-3 polyfills

我试图找出Google Maps v3和我们用于非 ES6浏览器(例如 IE11)的 polyfill 的问题。我们得到的错误是:

This site overrides Array.from() with an implementation that doesn't support iterables, which could cause Google Maps JavaScript API v3 to not work correctly.
Run Code Online (Sandbox Code Playgroud)

polyfill 是:(来自https://vanillajstoolkit.com/polyfills/arrayfrom/

if (!Array.from) {
  Array.from = (function () {
    var toStr = Object.prototype.toString;
    var isCallable = function (fn) {
      return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
    };
    var toInteger = function (value) {
      var number = Number(value);
      if (isNaN(number)) { return 0; }
      if (number === 0 || !isFinite(number)) { return number; }
      return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
    };
    var maxSafeInteger = Math.pow(2, 53) - 1;
    var toLength = function (value) {
      var len = toInteger(value);
      return Math.min(Math.max(len, 0), maxSafeInteger);
    };

    // The length property of the from method is 1.
    return function from(arrayLike/*, mapFn, thisArg */) {
      // 1. Let C be the this value.
      var C = this;

      // 2. Let items be ToObject(arrayLike).
      var items = Object(arrayLike);

      // 3. ReturnIfAbrupt(items).
      if (arrayLike == null) {
        throw new TypeError('Array.from requires an array-like object - not null or undefined');
      }

      // 4. If mapfn is undefined, then let mapping be false.
      var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
      var T;
      if (typeof mapFn !== 'undefined') {
        // 5. else
        // 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
        if (!isCallable(mapFn)) {
          throw new TypeError('Array.from: when provided, the second argument must be a function');
        }

        // 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
        if (arguments.length > 2) {
          T = arguments[2];
        }
      }

      // 10. Let lenValue be Get(items, "length").
      // 11. Let len be ToLength(lenValue).
      var len = toLength(items.length);

      // 13. If IsConstructor(C) is true, then
      // 13. a. Let A be the result of calling the [[Construct]] internal method
      // of C with an argument list containing the single item len.
      // 14. a. Else, Let A be ArrayCreate(len).
      var A = isCallable(C) ? Object(new C(len)) : new Array(len);

      // 16. Let k be 0.
      var k = 0;
      // 17. Repeat, while k < len… (also steps a - h)
      var kValue;
      while (k < len) {
        kValue = items[k];
        if (mapFn) {
          A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
        } else {
          A[k] = kValue;
        }
        k += 1;
      }
      // 18. Let putStatus be Put(A, "length", len, true).
      A.length = len;
      // 20. Return A.
      return A;
    };
  }());
}
Run Code Online (Sandbox Code Playgroud)

这在其他页面上运行良好 - 但出于某种原因,谷歌地图似乎有问题!

更令人沮丧的是,它随后破坏了我的其他插件之一(延迟加载脚本),在加载 Google 地图内容之前它可以正常工作

关于它的呻吟以及如何解决它的任何想法?

如果您有 IE11 或 VM,则可以在以下位置进行测试:https : //www.chambresdhotes.org/Detailed/1768.html(单击页面底部的地图,这将加载 Google 地图 - 但然后你会得到这个烦人的错误,它会破坏延迟加载之后的滚动)

谢谢!

小智 0

您好 Maps JavaScript API 客户:\n我们\xe2\x80\x99 谨此通知您,从版本 3.53 开始,Maps JavaScript API 对旧浏览器版本的被动支持将停止。\n我需要了解什么?\n我们正在更新 Maps JavaScript API 允许 ECMAScript 2020 (ES11) 功能,以确保 API 尽可能保持高性能和轻量级。为此,对于 ES11 级别以下的 JavaScript 功能,将不再自动包含命名空间包含的 polyfill。\n据我们所知,Chrome、Edge 和 Firefox 从版本 80 开始均支持 ES11 引入的功能。Safari 支持 ES11从版本 14.1 开始。\n请注意,所有这些浏览器版本都有 2-3 年历史,并且已经不受支持。\n我需要做什么?\n如果您的用户使用受支持浏览器的最新版本,您无需执行任何操作。否则,您可能需要暂时推迟使用 Maps JavaScript API 版本 3.53 及更高版本。或者,请确保您的应用程序和网页主动包含 Polyfill,以允许 ES11 级别的 JavaScript 依赖项。\n您已经可以通过使用 beta 通道加载 API(v=beta)来在您的应用程序和网页上测试此更改。\ n版本时间表\n请注意,特殊情况下,季度版本更新将于2023年4月下旬进行,而不是5月中旬。\n版本3.53将于2023年4月下旬加载到每周频道,并于2023年8月加载到季度频道。如有必要,可以在这些日期之前在加载 URL 中指定 v=3.52。这仅在版本 3.52 于 2024 年 2 月停用之前有效。

\n