]> git.openstreetmap.org Git - rails.git/blobdiff - vendor/assets/leaflet/leaflet.osm.js
Fix heatmap month titles in Western Hemisphere
[rails.git] / vendor / assets / leaflet / leaflet.osm.js
index 53d18bf2cecc83cf82506335528ff91227eb7f38..83cc3e2d6c778c15fd1ca02e10034348c41c99f2 100644 (file)
@@ -104,6 +104,13 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
     }
   },
 
+  loadingLayers: [],
+
+  cancelLoading: function () {
+    this.loadingLayers.forEach(layer => clearTimeout(layer));
+    this.loadingLayers = [];
+  },
+
   addData: function (features) {
     if (!(features instanceof Array)) {
       features = this.buildFeatures(features);
@@ -220,9 +227,11 @@ L.OSM.DataLayer = L.FeatureGroup.extend({
   eachLayer: function (method, context, asynchronous = false) {
     for (let i in this._layers) {
       if (asynchronous) {
-        setTimeout(() => {
-          method.call(context, this._layers[i]);
-        });
+        this.loadingLayers.push(
+          setTimeout(() => {
+            method.call(context, this._layers[i]);
+          })
+        );
       } else {
         method.call(context, this._layers[i]);
       }