@mattilsynet/design 2.2.28 → 2.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/mtds/alert/alert.js +8 -9
  2. package/mtds/alert/alert.js.map +1 -1
  3. package/mtds/analytics/analytics.js +104 -165
  4. package/mtds/analytics/analytics.js.map +1 -1
  5. package/mtds/app/app-observer.js +28 -74
  6. package/mtds/app/app-observer.js.map +1 -1
  7. package/mtds/app/app-toggle.js +26 -16
  8. package/mtds/app/app-toggle.js.map +1 -1
  9. package/mtds/app/app-toggle2.js +10 -4
  10. package/mtds/app/app-toggle2.js.map +1 -1
  11. package/mtds/app/app.js +32 -36
  12. package/mtds/app/app.js.map +1 -1
  13. package/mtds/atlas/atlas-element.d.ts +27 -0
  14. package/mtds/atlas/atlas-element.js +63 -84
  15. package/mtds/atlas/atlas-element.js.map +1 -1
  16. package/mtds/atlas/atlas-marker.js +28 -48
  17. package/mtds/atlas/atlas-marker.js.map +1 -1
  18. package/mtds/atlas/atlas-matgeo.d.ts +3 -8
  19. package/mtds/atlas/atlas-matgeo.js +36 -66
  20. package/mtds/atlas/atlas-matgeo.js.map +1 -1
  21. package/mtds/atlas/atlas-wms.js +11 -21
  22. package/mtds/atlas/atlas-wms.js.map +1 -1
  23. package/mtds/atlas/atlas.css.js +2 -2
  24. package/mtds/atlas/atlas.css.js.map +1 -1
  25. package/mtds/atlas/atlas.js +23 -23
  26. package/mtds/atlas/atlas.js.map +1 -1
  27. package/mtds/atlas/atlas.stories.d.ts +1 -0
  28. package/mtds/atlas/cluster.js +697 -1576
  29. package/mtds/atlas/cluster.js.map +1 -1
  30. package/mtds/atlas.iife.js +4 -4
  31. package/mtds/atlas.js +11 -10
  32. package/mtds/avatar/avatar.js +8 -8
  33. package/mtds/avatar/avatar.js.map +1 -1
  34. package/mtds/badge/badge.js +7 -7
  35. package/mtds/badge/badge.js.map +1 -1
  36. package/mtds/breadcrumbs/breadcrumbs-observer.js +9 -10
  37. package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
  38. package/mtds/breadcrumbs/breadcrumbs.js +13 -14
  39. package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
  40. package/mtds/button/button.js +14 -16
  41. package/mtds/button/button.js.map +1 -1
  42. package/mtds/card/card.js +12 -14
  43. package/mtds/card/card.js.map +1 -1
  44. package/mtds/chart/chart-axis.js +15 -27
  45. package/mtds/chart/chart-axis.js.map +1 -1
  46. package/mtds/chart/chart-bars.js +13 -15
  47. package/mtds/chart/chart-bars.js.map +1 -1
  48. package/mtds/chart/chart-element.js +48 -83
  49. package/mtds/chart/chart-element.js.map +1 -1
  50. package/mtds/chart/chart-lines.js +32 -54
  51. package/mtds/chart/chart-lines.js.map +1 -1
  52. package/mtds/chart/chart-pies.js +14 -34
  53. package/mtds/chart/chart-pies.js.map +1 -1
  54. package/mtds/chart/chart.css.js +2 -2
  55. package/mtds/chart/chart.css.js.map +1 -1
  56. package/mtds/chart/chart.js +12 -12
  57. package/mtds/chart/chart.js.map +1 -1
  58. package/mtds/chip/chip.js +8 -8
  59. package/mtds/chip/chip.js.map +1 -1
  60. package/mtds/chip/chip.stories.d.ts +1 -0
  61. package/mtds/details/details.js +12 -14
  62. package/mtds/details/details.js.map +1 -1
  63. package/mtds/dialog/dialog-observer.js +22 -35
  64. package/mtds/dialog/dialog-observer.js.map +1 -1
  65. package/mtds/dialog/dialog.js +12 -12
  66. package/mtds/dialog/dialog.js.map +1 -1
  67. package/mtds/divider/divider.js +10 -10
  68. package/mtds/divider/divider.js.map +1 -1
  69. package/mtds/errorsummary/errorsummary-observer.js +8 -11
  70. package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
  71. package/mtds/errorsummary/errorsummary.js +11 -11
  72. package/mtds/errorsummary/errorsummary.js.map +1 -1
  73. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js +19 -27
  74. package/mtds/external/@turf/boolean-point-in-polygon/dist/esm/index.js.map +1 -1
  75. package/mtds/external/@turf/helpers/dist/esm/index.js +16 -29
  76. package/mtds/external/@turf/helpers/dist/esm/index.js.map +1 -1
  77. package/mtds/external/@turf/invariant/dist/esm/index.js +13 -20
  78. package/mtds/external/@turf/invariant/dist/esm/index.js.map +1 -1
  79. package/mtds/external/leaflet/dist/leaflet-src.js +3096 -6004
  80. package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
  81. package/mtds/external/leaflet/dist/leaflet.css.js +2 -2
  82. package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
  83. package/mtds/external/point-in-polygon-hao/dist/esm/index.js +16 -46
  84. package/mtds/external/point-in-polygon-hao/dist/esm/index.js.map +1 -1
  85. package/mtds/external/robust-predicates/esm/orient2d.js +19 -163
  86. package/mtds/external/robust-predicates/esm/orient2d.js.map +1 -1
  87. package/mtds/external/robust-predicates/esm/util.js +25 -85
  88. package/mtds/external/robust-predicates/esm/util.js.map +1 -1
  89. package/mtds/field/field-observer.js +53 -119
  90. package/mtds/field/field-observer.js.map +1 -1
  91. package/mtds/field/field.d.ts +0 -1
  92. package/mtds/field/field.js +145 -177
  93. package/mtds/field/field.js.map +1 -1
  94. package/mtds/fieldset/fieldset-observer.js +14 -24
  95. package/mtds/fieldset/fieldset-observer.js.map +1 -1
  96. package/mtds/fieldset/fieldset.d.ts +3 -9
  97. package/mtds/fieldset/fieldset.js +20 -23
  98. package/mtds/fieldset/fieldset.js.map +1 -1
  99. package/mtds/fileupload/fileupload.js +8 -9
  100. package/mtds/fileupload/fileupload.js.map +1 -1
  101. package/mtds/fileupload/fileupload.stories.d.ts +1 -0
  102. package/mtds/helptext/helptext.js +15 -15
  103. package/mtds/helptext/helptext.js.map +1 -1
  104. package/mtds/illustrations/index.json +2 -2
  105. package/mtds/index.iife.js +15 -15
  106. package/mtds/index.js +27 -26
  107. package/mtds/index.js.map +1 -1
  108. package/mtds/input/input.js +28 -30
  109. package/mtds/input/input.js.map +1 -1
  110. package/mtds/law/law-helper.js +77 -143
  111. package/mtds/law/law-helper.js.map +1 -1
  112. package/mtds/law/law.js +6 -6
  113. package/mtds/law/law.js.map +1 -1
  114. package/mtds/layout/layout.js +10 -13
  115. package/mtds/layout/layout.js.map +1 -1
  116. package/mtds/link/link.js +7 -8
  117. package/mtds/link/link.js.map +1 -1
  118. package/mtds/logo/logo-observer.js +12 -18
  119. package/mtds/logo/logo-observer.js.map +1 -1
  120. package/mtds/logo/logo.js +8 -8
  121. package/mtds/logo/logo.js.map +1 -1
  122. package/mtds/package.json.js +2 -2
  123. package/mtds/pagination/pagination-helper.js +11 -17
  124. package/mtds/pagination/pagination-helper.js.map +1 -1
  125. package/mtds/pagination/pagination.js +30 -30
  126. package/mtds/pagination/pagination.js.map +1 -1
  127. package/mtds/popover/popover-observer.js +33 -45
  128. package/mtds/popover/popover-observer.js.map +1 -1
  129. package/mtds/popover/popover.js +12 -13
  130. package/mtds/popover/popover.js.map +1 -1
  131. package/mtds/progress/progress.js +8 -8
  132. package/mtds/progress/progress.js.map +1 -1
  133. package/mtds/react-atlas.js +13 -12
  134. package/mtds/react-types.d.ts +1 -0
  135. package/mtds/react.js +80 -80
  136. package/mtds/skeleton/skeleton.js +8 -8
  137. package/mtds/skeleton/skeleton.js.map +1 -1
  138. package/mtds/spinner/spinner.js +8 -8
  139. package/mtds/spinner/spinner.js.map +1 -1
  140. package/mtds/steps/steps.js +7 -7
  141. package/mtds/steps/steps.js.map +1 -1
  142. package/mtds/styles.css +1 -4591
  143. package/mtds/styles.json +43 -43
  144. package/mtds/styles.module.css.js +112 -167
  145. package/mtds/styles.module.css.js.map +1 -1
  146. package/mtds/table/table-observer.js +19 -22
  147. package/mtds/table/table-observer.js.map +1 -1
  148. package/mtds/table/table.d.ts +7 -0
  149. package/mtds/table/table.js +43 -18
  150. package/mtds/table/table.js.map +1 -1
  151. package/mtds/tabs/tabs.js +21 -25
  152. package/mtds/tabs/tabs.js.map +1 -1
  153. package/mtds/tag/tag.js +8 -8
  154. package/mtds/tag/tag.js.map +1 -1
  155. package/mtds/tailwind.css +6 -25
  156. package/mtds/toast/toast-helper.js +20 -35
  157. package/mtds/toast/toast-helper.js.map +1 -1
  158. package/mtds/toast/toast-observer.js +15 -30
  159. package/mtds/toast/toast-observer.js.map +1 -1
  160. package/mtds/toast/toast.js +37 -45
  161. package/mtds/toast/toast.js.map +1 -1
  162. package/mtds/togglegroup/togglegroup-observer.js +10 -15
  163. package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
  164. package/mtds/togglegroup/togglegroup.js +24 -21
  165. package/mtds/togglegroup/togglegroup.js.map +1 -1
  166. package/mtds/tooltip/tooltip-observer.js +32 -48
  167. package/mtds/tooltip/tooltip-observer.js.map +1 -1
  168. package/mtds/typography/typography.js +19 -28
  169. package/mtds/typography/typography.js.map +1 -1
  170. package/mtds/utils.js +89 -129
  171. package/mtds/utils.js.map +1 -1
  172. package/mtds/validation/validation-observer.d.ts +1 -0
  173. package/mtds/validation/validation-observer.js +31 -0
  174. package/mtds/validation/validation-observer.js.map +1 -0
  175. package/mtds/validation/validation.js +12 -12
  176. package/mtds/validation/validation.js.map +1 -1
  177. package/package.json +8 -6
@@ -1,30 +1,30 @@
1
- import L from "../external/leaflet/dist/leaflet-src.js";
2
- L.MarkerClusterGroup = L.FeatureGroup.extend({
1
+ import u from "../external/leaflet/dist/leaflet-src.js";
2
+ u.MarkerClusterGroup = u.FeatureGroup.extend({
3
3
  options: {
4
4
  maxClusterRadius: 80,
5
5
  //A cluster will cover at most this many pixels from its center
6
6
  iconCreateFunction: null,
7
- spiderfyOnMaxZoom: true,
8
- showCoverageOnHover: true,
9
- zoomToBoundsOnClick: true,
10
- singleMarkerMode: false,
7
+ spiderfyOnMaxZoom: !0,
8
+ showCoverageOnHover: !0,
9
+ zoomToBoundsOnClick: !0,
10
+ singleMarkerMode: !1,
11
11
  disableClusteringAtZoom: null,
12
12
  // Setting this to false prevents the removal of any clusters outside of the viewpoint, which
13
13
  // is the default behaviour for performance reasons.
14
- removeOutsideVisibleBounds: true,
14
+ removeOutsideVisibleBounds: !0,
15
15
  // Set to false to disable all animations (zoom and spiderfy).
16
16
  // If false, option animateAddingMarkers below has no effect.
17
17
  // If L.DomUtil.TRANSITION is falsy, this option has no effect.
18
- animate: true,
18
+ animate: !0,
19
19
  //Whether to animate adding markers after adding the MarkerClusterGroup to the map
20
20
  // If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains.
21
- animateAddingMarkers: false,
21
+ animateAddingMarkers: !1,
22
22
  //Increase to increase the distance away that spiderfied markers appear from the center
23
23
  spiderfyDistanceMultiplier: 1,
24
24
  // Make it possible to specify a polyline options on a spider leg
25
25
  spiderLegPolylineOptions: { weight: 1.5, color: "#222", opacity: 0.5 },
26
26
  // When bulk adding layers, adds markers in chunks. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts
27
- chunkedLoading: false,
27
+ chunkedLoading: !1,
28
28
  chunkInterval: 200,
29
29
  // process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback)
30
30
  chunkDelay: 50,
@@ -34,457 +34,211 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
34
34
  //Options to pass to the L.Polygon constructor
35
35
  polygonOptions: {}
36
36
  },
37
- initialize: function(options) {
38
- L.Util.setOptions(this, options);
39
- if (!this.options.iconCreateFunction) {
40
- this.options.iconCreateFunction = this._defaultIconCreateFunction;
41
- }
42
- if (!this.options.clusterPane) {
43
- this.options.clusterPane = L.Marker.prototype.options.pane;
44
- }
45
- this._featureGroup = new L.FeatureGroup();
46
- this._featureGroup.addEventParent(this);
47
- this._nonPointGroup = new L.FeatureGroup();
48
- this._nonPointGroup.addEventParent(this);
49
- this._inZoomAnimation = 0;
50
- this._needsClustering = [];
51
- this._needsRemoving = [];
52
- this._currentShownBounds = null;
53
- this._queue = [];
54
- this._childMarkerEventHandlers = {
37
+ initialize: function(t) {
38
+ u.Util.setOptions(this, t), this.options.iconCreateFunction || (this.options.iconCreateFunction = this._defaultIconCreateFunction), this.options.clusterPane || (this.options.clusterPane = u.Marker.prototype.options.pane), this._featureGroup = new u.FeatureGroup(), this._featureGroup.addEventParent(this), this._nonPointGroup = new u.FeatureGroup(), this._nonPointGroup.addEventParent(this), this._inZoomAnimation = 0, this._needsClustering = [], this._needsRemoving = [], this._currentShownBounds = null, this._queue = [], this._childMarkerEventHandlers = {
55
39
  dragstart: this._childMarkerDragStart,
56
40
  move: this._childMarkerMoved,
57
41
  dragend: this._childMarkerDragEnd
58
42
  };
59
- var animate = L.DomUtil.TRANSITION && this.options.animate;
60
- Object.assign(this, animate ? this._withAnimation : this._noAnimation);
61
- this._markerCluster = animate ? L.MarkerCluster : L.MarkerClusterNonAnimated;
62
- },
63
- addLayer: function(layer) {
64
- if (layer instanceof L.LayerGroup) {
65
- return this.addLayers([layer]);
66
- }
67
- if (!layer.getLatLng) {
68
- this._nonPointGroup.addLayer(layer);
69
- this.fire("layeradd", { layer, propagatedFrom: layer });
43
+ var e = u.DomUtil.TRANSITION && this.options.animate;
44
+ Object.assign(this, e ? this._withAnimation : this._noAnimation), this._markerCluster = e ? u.MarkerCluster : u.MarkerClusterNonAnimated;
45
+ },
46
+ addLayer: function(t) {
47
+ if (t instanceof u.LayerGroup)
48
+ return this.addLayers([t]);
49
+ if (!t.getLatLng)
50
+ return this._nonPointGroup.addLayer(t), this.fire("layeradd", { layer: t, propagatedFrom: t }), this;
51
+ if (!this._map)
52
+ return this._needsClustering.push(t), this.fire("layeradd", { layer: t, propagatedFrom: t }), this;
53
+ if (this.hasLayer(t))
70
54
  return this;
71
- }
72
- if (!this._map) {
73
- this._needsClustering.push(layer);
74
- this.fire("layeradd", { layer, propagatedFrom: layer });
75
- return this;
76
- }
77
- if (this.hasLayer(layer)) {
78
- return this;
79
- }
80
- if (this._unspiderfy) {
81
- this._unspiderfy();
82
- }
83
- this._addLayer(layer, this._maxZoom);
84
- this.fire("layeradd", { layer, propagatedFrom: layer });
85
- this._topClusterLevel._recalculateBounds();
86
- this._refreshClustersIcons();
87
- var visibleLayer = layer, currentZoom = this._zoom;
88
- if (layer.__parent) {
89
- while (visibleLayer.__parent._zoom >= currentZoom) {
90
- visibleLayer = visibleLayer.__parent;
91
- }
92
- }
93
- if (this._currentShownBounds.contains(visibleLayer.getLatLng())) {
94
- if (this.options.animateAddingMarkers) {
95
- this._animationAddLayer(layer, visibleLayer);
96
- } else {
97
- this._animationAddLayerNonAnimated(layer, visibleLayer);
98
- }
99
- }
100
- return this;
55
+ this._unspiderfy && this._unspiderfy(), this._addLayer(t, this._maxZoom), this.fire("layeradd", { layer: t, propagatedFrom: t }), this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons();
56
+ var e = t, i = this._zoom;
57
+ if (t.__parent)
58
+ for (; e.__parent._zoom >= i; )
59
+ e = e.__parent;
60
+ return this._currentShownBounds.contains(e.getLatLng()) && (this.options.animateAddingMarkers ? this._animationAddLayer(t, e) : this._animationAddLayerNonAnimated(t, e)), this;
101
61
  },
102
- removeLayer: function(layer) {
103
- if (layer instanceof L.LayerGroup) {
104
- return this.removeLayers([layer]);
105
- }
106
- if (!layer.getLatLng) {
107
- this._nonPointGroup.removeLayer(layer);
108
- this.fire("layerremove", { layer, propagatedFrom: layer });
109
- return this;
110
- }
111
- if (!this._map) {
112
- if (!this._arraySplice(this._needsClustering, layer) && this.hasLayer(layer)) {
113
- this._needsRemoving.push({ layer, latlng: layer._latlng });
114
- }
115
- this.fire("layerremove", { layer, propagatedFrom: layer });
116
- return this;
117
- }
118
- if (!layer.__parent) {
119
- return this;
120
- }
121
- if (this._unspiderfy) {
122
- this._unspiderfy();
123
- this._unspiderfyLayer(layer);
124
- }
125
- this._removeLayer(layer, true);
126
- this.fire("layerremove", { layer, propagatedFrom: layer });
127
- this._topClusterLevel._recalculateBounds();
128
- this._refreshClustersIcons();
129
- layer.off(this._childMarkerEventHandlers, this);
130
- if (this._featureGroup.hasLayer(layer)) {
131
- this._featureGroup.removeLayer(layer);
132
- if (layer.clusterShow) {
133
- layer.clusterShow();
134
- }
135
- }
136
- return this;
62
+ removeLayer: function(t) {
63
+ return t instanceof u.LayerGroup ? this.removeLayers([t]) : t.getLatLng ? this._map ? t.__parent ? (this._unspiderfy && (this._unspiderfy(), this._unspiderfyLayer(t)), this._removeLayer(t, !0), this.fire("layerremove", { layer: t, propagatedFrom: t }), this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons(), t.off(this._childMarkerEventHandlers, this), this._featureGroup.hasLayer(t) && (this._featureGroup.removeLayer(t), t.clusterShow && t.clusterShow()), this) : this : (!this._arraySplice(this._needsClustering, t) && this.hasLayer(t) && this._needsRemoving.push({ layer: t, latlng: t._latlng }), this.fire("layerremove", { layer: t, propagatedFrom: t }), this) : (this._nonPointGroup.removeLayer(t), this.fire("layerremove", { layer: t, propagatedFrom: t }), this);
137
64
  },
138
65
  //Takes an array of markers and adds them in bulk
139
- addLayers: function(layersArray, skipLayerAddEvent) {
140
- if (!Array.isArray(layersArray)) return this.addLayer(layersArray);
141
- var fg = this._featureGroup, npg = this._nonPointGroup, chunked = this.options.chunkedLoading, chunkInterval = this.options.chunkInterval, chunkProgress = this.options.chunkProgress, l = layersArray.length, offset = 0, originalArray = true, m;
66
+ addLayers: function(t, e) {
67
+ if (!Array.isArray(t)) return this.addLayer(t);
68
+ var i = this._featureGroup, n = this._nonPointGroup, s = this.options.chunkedLoading, o = this.options.chunkInterval, r = this.options.chunkProgress, a = t.length, h = 0, _ = !0, l;
142
69
  if (this._map) {
143
- const started = Date.now();
144
- const process = () => {
145
- var start = Date.now();
146
- for (; offset < l; offset++) {
147
- if (chunked && offset % 200 === 0) {
148
- const elapsed = Date.now() - start;
149
- if (elapsed > chunkInterval) {
150
- break;
151
- }
152
- }
153
- m = layersArray[offset];
154
- if (m instanceof L.LayerGroup) {
155
- if (originalArray) {
156
- layersArray = layersArray.slice();
157
- originalArray = false;
158
- }
159
- this._extractNonGroupLayers(m, layersArray);
160
- l = layersArray.length;
70
+ const d = Date.now(), p = () => {
71
+ for (var f = Date.now(); h < a && !(s && h % 200 === 0 && Date.now() - f > o); h++) {
72
+ if (l = t[h], l instanceof u.LayerGroup) {
73
+ _ && (t = t.slice(), _ = !1), this._extractNonGroupLayers(l, t), a = t.length;
161
74
  continue;
162
75
  }
163
- if (!m.getLatLng) {
164
- npg.addLayer(m);
165
- if (!skipLayerAddEvent) {
166
- this.fire("layeradd", { layer: m, propagatedFrom: m });
167
- }
76
+ if (!l.getLatLng) {
77
+ n.addLayer(l), e || this.fire("layeradd", { layer: l, propagatedFrom: l });
168
78
  continue;
169
79
  }
170
- if (this.hasLayer(m)) {
171
- continue;
172
- }
173
- this._addLayer(m, this._maxZoom);
174
- if (!skipLayerAddEvent) {
175
- this.fire("layeradd", { layer: m, propagatedFrom: m });
176
- }
177
- if (m.__parent) {
178
- if (m.__parent.getChildCount() === 2) {
179
- const markers = m.__parent.getAllChildMarkers();
180
- const otherMarker = markers[0] === m ? markers[1] : markers[0];
181
- fg.removeLayer(otherMarker);
182
- }
80
+ if (!this.hasLayer(l) && (this._addLayer(l, this._maxZoom), e || this.fire("layeradd", { layer: l, propagatedFrom: l }), l.__parent && l.__parent.getChildCount() === 2)) {
81
+ const c = l.__parent.getAllChildMarkers(), g = c[0] === l ? c[1] : c[0];
82
+ i.removeLayer(g);
183
83
  }
184
84
  }
185
- if (chunkProgress) {
186
- chunkProgress(offset, l, Date.now() - started);
187
- }
188
- if (offset === l) {
189
- this._topClusterLevel._recalculateBounds();
190
- this._refreshClustersIcons();
191
- this._topClusterLevel._recursivelyAddChildrenToMap(
192
- null,
193
- this._zoom,
194
- this._currentShownBounds
195
- );
196
- } else {
197
- setTimeout(process, this.options.chunkDelay);
198
- }
85
+ r && r(h, a, Date.now() - d), h === a ? (this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons(), this._topClusterLevel._recursivelyAddChildrenToMap(
86
+ null,
87
+ this._zoom,
88
+ this._currentShownBounds
89
+ )) : setTimeout(p, this.options.chunkDelay);
199
90
  };
200
- process();
91
+ p();
201
92
  } else {
202
- const needsClustering = this._needsClustering;
203
- for (; offset < l; offset++) {
204
- m = layersArray[offset];
205
- if (m instanceof L.LayerGroup) {
206
- if (originalArray) {
207
- layersArray = layersArray.slice();
208
- originalArray = false;
209
- }
210
- this._extractNonGroupLayers(m, layersArray);
211
- l = layersArray.length;
212
- continue;
213
- }
214
- if (!m.getLatLng) {
215
- npg.addLayer(m);
93
+ const d = this._needsClustering;
94
+ for (; h < a; h++) {
95
+ if (l = t[h], l instanceof u.LayerGroup) {
96
+ _ && (t = t.slice(), _ = !1), this._extractNonGroupLayers(l, t), a = t.length;
216
97
  continue;
217
98
  }
218
- if (this.hasLayer(m)) {
99
+ if (!l.getLatLng) {
100
+ n.addLayer(l);
219
101
  continue;
220
102
  }
221
- needsClustering.push(m);
103
+ this.hasLayer(l) || d.push(l);
222
104
  }
223
105
  }
224
106
  return this;
225
107
  },
226
108
  //Takes an array of markers and removes them in bulk
227
- removeLayers: function(layersArray) {
228
- var i, m, l = layersArray.length, fg = this._featureGroup, npg = this._nonPointGroup, originalArray = true;
109
+ removeLayers: function(t) {
110
+ var e, i, n = t.length, s = this._featureGroup, o = this._nonPointGroup, r = !0;
229
111
  if (!this._map) {
230
- for (i = 0; i < l; i++) {
231
- m = layersArray[i];
232
- if (m instanceof L.LayerGroup) {
233
- if (originalArray) {
234
- layersArray = layersArray.slice();
235
- originalArray = false;
236
- }
237
- this._extractNonGroupLayers(m, layersArray);
238
- l = layersArray.length;
112
+ for (e = 0; e < n; e++) {
113
+ if (i = t[e], i instanceof u.LayerGroup) {
114
+ r && (t = t.slice(), r = !1), this._extractNonGroupLayers(i, t), n = t.length;
239
115
  continue;
240
116
  }
241
- this._arraySplice(this._needsClustering, m);
242
- npg.removeLayer(m);
243
- if (this.hasLayer(m)) {
244
- this._needsRemoving.push({ layer: m, latlng: m._latlng });
245
- }
246
- this.fire("layerremove", { layer: m, propagatedFrom: m });
117
+ this._arraySplice(this._needsClustering, i), o.removeLayer(i), this.hasLayer(i) && this._needsRemoving.push({ layer: i, latlng: i._latlng }), this.fire("layerremove", { layer: i, propagatedFrom: i });
247
118
  }
248
119
  return this;
249
120
  }
250
121
  if (this._unspiderfy) {
251
122
  this._unspiderfy();
252
- const layersArray2 = layersArray.slice();
253
- let l2 = l;
254
- for (i = 0; i < l2; i++) {
255
- m = layersArray2[i];
256
- if (m instanceof L.LayerGroup) {
257
- this._extractNonGroupLayers(m, layersArray2);
258
- l2 = layersArray2.length;
123
+ const a = t.slice();
124
+ let h = n;
125
+ for (e = 0; e < h; e++) {
126
+ if (i = a[e], i instanceof u.LayerGroup) {
127
+ this._extractNonGroupLayers(i, a), h = a.length;
259
128
  continue;
260
129
  }
261
- this._unspiderfyLayer(m);
130
+ this._unspiderfyLayer(i);
262
131
  }
263
132
  }
264
- for (i = 0; i < l; i++) {
265
- m = layersArray[i];
266
- if (m instanceof L.LayerGroup) {
267
- if (originalArray) {
268
- layersArray = layersArray.slice();
269
- originalArray = false;
270
- }
271
- this._extractNonGroupLayers(m, layersArray);
272
- l = layersArray.length;
133
+ for (e = 0; e < n; e++) {
134
+ if (i = t[e], i instanceof u.LayerGroup) {
135
+ r && (t = t.slice(), r = !1), this._extractNonGroupLayers(i, t), n = t.length;
273
136
  continue;
274
137
  }
275
- if (!m.__parent) {
276
- npg.removeLayer(m);
277
- this.fire("layerremove", { layer: m, propagatedFrom: m });
138
+ if (!i.__parent) {
139
+ o.removeLayer(i), this.fire("layerremove", { layer: i, propagatedFrom: i });
278
140
  continue;
279
141
  }
280
- this._removeLayer(m, true, true);
281
- this.fire("layerremove", { layer: m, propagatedFrom: m });
282
- if (fg.hasLayer(m)) {
283
- fg.removeLayer(m);
284
- if (m.clusterShow) {
285
- m.clusterShow();
286
- }
287
- }
142
+ this._removeLayer(i, !0, !0), this.fire("layerremove", { layer: i, propagatedFrom: i }), s.hasLayer(i) && (s.removeLayer(i), i.clusterShow && i.clusterShow());
288
143
  }
289
- this._topClusterLevel._recalculateBounds();
290
- this._refreshClustersIcons();
291
- this._topClusterLevel._recursivelyAddChildrenToMap(
144
+ return this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons(), this._topClusterLevel._recursivelyAddChildrenToMap(
292
145
  null,
293
146
  this._zoom,
294
147
  this._currentShownBounds
295
- );
296
- return this;
148
+ ), this;
297
149
  },
298
150
  //Removes all layers from the MarkerClusterGroup
299
151
  clearLayers: function() {
300
- if (!this._map) {
301
- this._needsClustering = [];
302
- delete this._gridClusters;
303
- delete this._gridUnclustered;
304
- }
305
- if (this._noanimationUnspiderfy) {
306
- this._noanimationUnspiderfy();
307
- }
308
- this._featureGroup.clearLayers();
309
- this._nonPointGroup.clearLayers();
310
- this.eachLayer(function(marker) {
311
- marker.off(this._childMarkerEventHandlers, this);
312
- delete marker.__parent;
313
- }, this);
314
- if (this._map) {
315
- this._generateInitialClusters();
316
- }
317
- return this;
152
+ return this._map || (this._needsClustering = [], delete this._gridClusters, delete this._gridUnclustered), this._noanimationUnspiderfy && this._noanimationUnspiderfy(), this._featureGroup.clearLayers(), this._nonPointGroup.clearLayers(), this.eachLayer(function(t) {
153
+ t.off(this._childMarkerEventHandlers, this), delete t.__parent;
154
+ }, this), this._map && this._generateInitialClusters(), this;
318
155
  },
319
156
  //Override FeatureGroup.getBounds as it doesn't work
320
157
  getBounds: function() {
321
- var bounds = new L.LatLngBounds();
322
- if (this._topClusterLevel) {
323
- bounds.extend(this._topClusterLevel._bounds);
324
- }
325
- for (let i = this._needsClustering.length - 1; i >= 0; i--) {
326
- bounds.extend(this._needsClustering[i].getLatLng());
327
- }
328
- bounds.extend(this._nonPointGroup.getBounds());
329
- return bounds;
158
+ var t = new u.LatLngBounds();
159
+ this._topClusterLevel && t.extend(this._topClusterLevel._bounds);
160
+ for (let e = this._needsClustering.length - 1; e >= 0; e--)
161
+ t.extend(this._needsClustering[e].getLatLng());
162
+ return t.extend(this._nonPointGroup.getBounds()), t;
330
163
  },
331
164
  //Overrides LayerGroup.eachLayer
332
- eachLayer: function(method, context) {
333
- var markers = this._needsClustering.slice(), needsRemoving = this._needsRemoving, thisNeedsRemoving, i, j;
334
- if (this._topClusterLevel) {
335
- this._topClusterLevel.getAllChildMarkers(markers);
336
- }
337
- for (i = markers.length - 1; i >= 0; i--) {
338
- thisNeedsRemoving = true;
339
- for (j = needsRemoving.length - 1; j >= 0; j--) {
340
- if (needsRemoving[j].layer === markers[i]) {
341
- thisNeedsRemoving = false;
165
+ eachLayer: function(t, e) {
166
+ var i = this._needsClustering.slice(), n = this._needsRemoving, s, o, r;
167
+ for (this._topClusterLevel && this._topClusterLevel.getAllChildMarkers(i), o = i.length - 1; o >= 0; o--) {
168
+ for (s = !0, r = n.length - 1; r >= 0; r--)
169
+ if (n[r].layer === i[o]) {
170
+ s = !1;
342
171
  break;
343
172
  }
344
- }
345
- if (thisNeedsRemoving) {
346
- method.call(context, markers[i]);
347
- }
173
+ s && t.call(e, i[o]);
348
174
  }
349
- this._nonPointGroup.eachLayer(method, context);
175
+ this._nonPointGroup.eachLayer(t, e);
350
176
  },
351
177
  //Overrides LayerGroup.getLayers
352
178
  getLayers: function() {
353
- var layers = [];
354
- this.eachLayer((l) => {
355
- layers.push(l);
356
- });
357
- return layers;
179
+ var t = [];
180
+ return this.eachLayer((e) => {
181
+ t.push(e);
182
+ }), t;
358
183
  },
359
184
  //Overrides LayerGroup.getLayer, WARNING: Really bad performance
360
- getLayer: function(id) {
361
- var result = null;
362
- id = parseInt(id, 10);
363
- this.eachLayer((l) => {
364
- if (L.stamp(l) === id) {
365
- result = l;
366
- }
367
- });
368
- return result;
185
+ getLayer: function(t) {
186
+ var e = null;
187
+ return t = parseInt(t, 10), this.eachLayer((i) => {
188
+ u.stamp(i) === t && (e = i);
189
+ }), e;
369
190
  },
370
191
  //Returns true if the given layer is in this MarkerClusterGroup
371
- hasLayer: function(layer) {
372
- if (!layer) {
373
- return false;
374
- }
375
- var i, anArray = this._needsClustering;
376
- for (i = anArray.length - 1; i >= 0; i--) {
377
- if (anArray[i] === layer) {
378
- return true;
379
- }
380
- }
381
- anArray = this._needsRemoving;
382
- for (i = anArray.length - 1; i >= 0; i--) {
383
- if (anArray[i].layer === layer) {
384
- return false;
385
- }
386
- }
387
- return !!(layer.__parent && layer.__parent._group === this) || this._nonPointGroup.hasLayer(layer);
192
+ hasLayer: function(t) {
193
+ if (!t)
194
+ return !1;
195
+ var e, i = this._needsClustering;
196
+ for (e = i.length - 1; e >= 0; e--)
197
+ if (i[e] === t)
198
+ return !0;
199
+ for (i = this._needsRemoving, e = i.length - 1; e >= 0; e--)
200
+ if (i[e].layer === t)
201
+ return !1;
202
+ return !!(t.__parent && t.__parent._group === this) || this._nonPointGroup.hasLayer(t);
388
203
  },
389
204
  //Zoom down to show the given layer (spiderfying if necessary) then calls the callback
390
- zoomToShowLayer: function(layer, callback) {
391
- if (typeof callback !== "function") {
392
- callback = () => {
393
- };
394
- }
395
- var showMarker = function() {
396
- if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation) {
397
- this._map.off("moveend", showMarker, this);
398
- this.off("animationend", showMarker, this);
399
- if (layer._icon) {
400
- callback();
401
- } else if (layer.__parent._icon) {
402
- this.once("spiderfied", callback, this);
403
- layer.__parent.spiderfy();
404
- }
405
- }
205
+ zoomToShowLayer: function(t, e) {
206
+ typeof e != "function" && (e = () => {
207
+ });
208
+ var i = function() {
209
+ (t._icon || t.__parent._icon) && !this._inZoomAnimation && (this._map.off("moveend", i, this), this.off("animationend", i, this), t._icon ? e() : t.__parent._icon && (this.once("spiderfied", e, this), t.__parent.spiderfy()));
406
210
  };
407
- if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) {
408
- callback();
409
- } else if (layer.__parent._zoom < Math.round(this._map._zoom)) {
410
- this._map.on("moveend", showMarker, this);
411
- this._map.panTo(layer.getLatLng());
412
- } else {
413
- this._map.on("moveend", showMarker, this);
414
- this.on("animationend", showMarker, this);
415
- layer.__parent.zoomToBounds();
416
- }
211
+ t._icon && this._map.getBounds().contains(t.getLatLng()) ? e() : t.__parent._zoom < Math.round(this._map._zoom) ? (this._map.on("moveend", i, this), this._map.panTo(t.getLatLng())) : (this._map.on("moveend", i, this), this.on("animationend", i, this), t.__parent.zoomToBounds());
417
212
  },
418
213
  //Overrides FeatureGroup.onAdd
419
- onAdd: function(map) {
420
- this._map = map;
421
- var i, l, layer;
422
- if (!Number.isFinite(this._map.getMaxZoom())) {
214
+ onAdd: function(t) {
215
+ this._map = t;
216
+ var e, i, n;
217
+ if (!Number.isFinite(this._map.getMaxZoom()))
423
218
  throw "Map has no maxZoom specified";
424
- }
425
- this._featureGroup.addTo(map);
426
- this._nonPointGroup.addTo(map);
427
- if (!this._gridClusters) {
428
- this._generateInitialClusters();
429
- }
430
- this._maxLat = map.options.crs.projection.MAX_LATITUDE;
431
- for (i = 0, l = this._needsRemoving.length; i < l; i++) {
432
- layer = this._needsRemoving[i];
433
- layer.newlatlng = layer.layer._latlng;
434
- layer.layer._latlng = layer.latlng;
435
- }
436
- for (i = 0, l = this._needsRemoving.length; i < l; i++) {
437
- layer = this._needsRemoving[i];
438
- this._removeLayer(layer.layer, true);
439
- layer.layer._latlng = layer.newlatlng;
440
- }
441
- this._needsRemoving = [];
442
- this._zoom = Math.round(this._map._zoom);
443
- this._currentShownBounds = this._getExpandedVisibleBounds();
444
- this._map.on("zoomend", this._zoomEnd, this);
445
- this._map.on("moveend", this._moveEnd, this);
446
- if (this._spiderfierOnAdd) {
447
- this._spiderfierOnAdd();
448
- }
449
- this._bindEvents();
450
- l = this._needsClustering;
451
- this._needsClustering = [];
452
- this.addLayers(l, true);
219
+ for (this._featureGroup.addTo(t), this._nonPointGroup.addTo(t), this._gridClusters || this._generateInitialClusters(), this._maxLat = t.options.crs.projection.MAX_LATITUDE, e = 0, i = this._needsRemoving.length; e < i; e++)
220
+ n = this._needsRemoving[e], n.newlatlng = n.layer._latlng, n.layer._latlng = n.latlng;
221
+ for (e = 0, i = this._needsRemoving.length; e < i; e++)
222
+ n = this._needsRemoving[e], this._removeLayer(n.layer, !0), n.layer._latlng = n.newlatlng;
223
+ this._needsRemoving = [], this._zoom = Math.round(this._map._zoom), this._currentShownBounds = this._getExpandedVisibleBounds(), this._map.on("zoomend", this._zoomEnd, this), this._map.on("moveend", this._moveEnd, this), this._spiderfierOnAdd && this._spiderfierOnAdd(), this._bindEvents(), i = this._needsClustering, this._needsClustering = [], this.addLayers(i, !0);
453
224
  },
454
225
  //Overrides FeatureGroup.onRemove
455
- onRemove: function(map) {
456
- map.off("zoomend", this._zoomEnd, this);
457
- map.off("moveend", this._moveEnd, this);
458
- this._unbindEvents();
459
- this._map._mapPane.className = this._map._mapPane.className.replace(
226
+ onRemove: function(t) {
227
+ t.off("zoomend", this._zoomEnd, this), t.off("moveend", this._moveEnd, this), this._unbindEvents(), this._map._mapPane.className = this._map._mapPane.className.replace(
460
228
  " leaflet-cluster-anim",
461
229
  ""
462
- );
463
- if (this._spiderfierOnRemove) {
464
- this._spiderfierOnRemove();
465
- }
466
- delete this._maxLat;
467
- this._hideCoverage();
468
- this._featureGroup.remove();
469
- this._nonPointGroup.remove();
470
- this._featureGroup.clearLayers();
471
- this._map = null;
472
- },
473
- getVisibleParent: (marker) => {
474
- var vMarker = marker;
475
- while (vMarker && !vMarker._icon) {
476
- vMarker = vMarker.__parent;
477
- }
478
- return vMarker || null;
230
+ ), this._spiderfierOnRemove && this._spiderfierOnRemove(), delete this._maxLat, this._hideCoverage(), this._featureGroup.remove(), this._nonPointGroup.remove(), this._featureGroup.clearLayers(), this._map = null;
231
+ },
232
+ getVisibleParent: (t) => {
233
+ for (var e = t; e && !e._icon; )
234
+ e = e.__parent;
235
+ return e || null;
479
236
  },
480
237
  //Remove the given object from the given array
481
- _arraySplice: (anArray, obj) => {
482
- for (let i = anArray.length - 1; i >= 0; i--) {
483
- if (anArray[i] === obj) {
484
- anArray.splice(i, 1);
485
- return true;
486
- }
487
- }
238
+ _arraySplice: (t, e) => {
239
+ for (let i = t.length - 1; i >= 0; i--)
240
+ if (t[i] === e)
241
+ return t.splice(i, 1), !0;
488
242
  },
489
243
  /**
490
244
  * Removes a marker from all _gridUnclustered zoom levels, starting at the supplied zoom.
@@ -492,269 +246,157 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
492
246
  * @param z integer bottom start zoom level (included)
493
247
  * @private
494
248
  */
495
- _removeFromGridUnclustered: function(marker, z) {
496
- var map = this._map, gridUnclustered = this._gridUnclustered, minZoom = Math.floor(this._map.getMinZoom());
497
- for (; z >= minZoom; z--) {
498
- if (!gridUnclustered[z].removeObject(
499
- marker,
500
- map.project(marker.getLatLng(), z)
501
- )) {
502
- break;
503
- }
504
- }
249
+ _removeFromGridUnclustered: function(t, e) {
250
+ for (var i = this._map, n = this._gridUnclustered, s = Math.floor(this._map.getMinZoom()); e >= s && n[e].removeObject(
251
+ t,
252
+ i.project(t.getLatLng(), e)
253
+ ); e--)
254
+ ;
505
255
  },
506
- _childMarkerDragStart: (e) => {
507
- e.target.__dragStart = e.target._latlng;
256
+ _childMarkerDragStart: (t) => {
257
+ t.target.__dragStart = t.target._latlng;
508
258
  },
509
- _childMarkerMoved: function(e) {
510
- if (!this._ignoreMove && !e.target.__dragStart) {
511
- const isPopupOpen = (e.target._popup || null)?.isOpen();
512
- this._moveChild(e.target, e.oldLatLng, e.latlng);
513
- if (isPopupOpen) {
514
- e.target.openPopup();
515
- }
259
+ _childMarkerMoved: function(t) {
260
+ if (!this._ignoreMove && !t.target.__dragStart) {
261
+ const e = (t.target._popup || null)?.isOpen();
262
+ this._moveChild(t.target, t.oldLatLng, t.latlng), e && t.target.openPopup();
516
263
  }
517
264
  },
518
- _moveChild: function(layer, from, to) {
519
- layer._latlng = from;
520
- this.removeLayer(layer);
521
- layer._latlng = to;
522
- this.addLayer(layer);
265
+ _moveChild: function(t, e, i) {
266
+ t._latlng = e, this.removeLayer(t), t._latlng = i, this.addLayer(t);
523
267
  },
524
- _childMarkerDragEnd: function(e) {
525
- if (e.target.__dragStart) {
526
- this._moveChild(e.target, e.target.__dragStart, e.target._latlng);
527
- }
528
- delete e.target.__dragStart;
268
+ _childMarkerDragEnd: function(t) {
269
+ t.target.__dragStart && this._moveChild(t.target, t.target.__dragStart, t.target._latlng), delete t.target.__dragStart;
529
270
  },
530
271
  //Internal function for removing a marker from everything.
531
272
  //dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions)
532
- _removeLayer: function(marker, removeFromDistanceGrid, dontUpdateMap) {
533
- var gridClusters = this._gridClusters, gridUnclustered = this._gridUnclustered, fg = this._featureGroup, map = this._map, minZoom = Math.floor(this._map.getMinZoom());
534
- if (removeFromDistanceGrid) {
535
- this._removeFromGridUnclustered(marker, this._maxZoom);
536
- }
537
- var cluster = marker.__parent, markers = cluster._markers, otherMarker;
538
- this._arraySplice(markers, marker);
539
- while (cluster) {
540
- cluster._childCount--;
541
- cluster._boundsNeedUpdate = true;
542
- if (cluster._zoom < minZoom) {
543
- break;
544
- } else if (removeFromDistanceGrid && cluster._childCount <= 1) {
545
- otherMarker = cluster._markers[0] === marker ? cluster._markers[1] : cluster._markers[0];
546
- gridClusters[cluster._zoom].removeObject(
547
- cluster,
548
- map.project(cluster._cLatLng, cluster._zoom)
549
- );
550
- gridUnclustered[cluster._zoom].addObject(
551
- otherMarker,
552
- map.project(otherMarker.getLatLng(), cluster._zoom)
553
- );
554
- this._arraySplice(cluster.__parent._childClusters, cluster);
555
- cluster.__parent._markers.push(otherMarker);
556
- otherMarker.__parent = cluster.__parent;
557
- if (cluster._icon) {
558
- fg.removeLayer(cluster);
559
- if (!dontUpdateMap) {
560
- fg.addLayer(otherMarker);
561
- }
562
- }
563
- } else {
564
- cluster._iconNeedsUpdate = true;
565
- }
566
- cluster = cluster.__parent;
567
- }
568
- delete marker.__parent;
569
- },
570
- _isOrIsParent: (el, oel) => {
571
- while (oel) {
572
- if (el === oel) return true;
573
- oel = oel.parentNode;
574
- }
575
- return false;
273
+ _removeLayer: function(t, e, i) {
274
+ var n = this._gridClusters, s = this._gridUnclustered, o = this._featureGroup, r = this._map, a = Math.floor(this._map.getMinZoom());
275
+ e && this._removeFromGridUnclustered(t, this._maxZoom);
276
+ var h = t.__parent, _ = h._markers, l;
277
+ for (this._arraySplice(_, t); h && (h._childCount--, h._boundsNeedUpdate = !0, !(h._zoom < a)); )
278
+ e && h._childCount <= 1 ? (l = h._markers[0] === t ? h._markers[1] : h._markers[0], n[h._zoom].removeObject(
279
+ h,
280
+ r.project(h._cLatLng, h._zoom)
281
+ ), s[h._zoom].addObject(
282
+ l,
283
+ r.project(l.getLatLng(), h._zoom)
284
+ ), this._arraySplice(h.__parent._childClusters, h), h.__parent._markers.push(l), l.__parent = h.__parent, h._icon && (o.removeLayer(h), i || o.addLayer(l))) : h._iconNeedsUpdate = !0, h = h.__parent;
285
+ delete t.__parent;
286
+ },
287
+ _isOrIsParent: (t, e) => {
288
+ for (; e; ) {
289
+ if (t === e) return !0;
290
+ e = e.parentNode;
291
+ }
292
+ return !1;
576
293
  },
577
294
  //Override L.Evented.fire
578
- fire: function(type, e, propagate) {
579
- if (e && e.propagatedFrom instanceof L.MarkerCluster) {
295
+ fire: function(t, e, i) {
296
+ if (e && e.propagatedFrom instanceof u.MarkerCluster) {
580
297
  if (e.originalEvent && this._isOrIsParent(
581
298
  e.propagatedFrom._icon,
582
299
  e.originalEvent.relatedTarget
583
300
  ))
584
301
  return;
585
- type = `cluster${type}`;
302
+ t = `cluster${t}`;
586
303
  }
587
- L.FeatureGroup.prototype.fire.call(this, type, e, propagate);
304
+ u.FeatureGroup.prototype.fire.call(this, t, e, i);
588
305
  },
589
306
  //Override L.Evented.listens
590
- listens: function(type, propagate) {
591
- return L.FeatureGroup.prototype.listens.call(this, type, propagate) || L.FeatureGroup.prototype.listens.call(this, `cluster${type}`, propagate);
307
+ listens: function(t, e) {
308
+ return u.FeatureGroup.prototype.listens.call(this, t, e) || u.FeatureGroup.prototype.listens.call(this, `cluster${t}`, e);
592
309
  },
593
310
  //Default functionality
594
- _defaultIconCreateFunction: (cluster) => {
595
- const childCount = cluster.getChildCount();
596
- let c = " marker-cluster-";
597
- if (childCount < 10) {
598
- c += "small";
599
- } else if (childCount < 100) {
600
- c += "medium";
601
- } else {
602
- c += "large";
603
- }
604
- return new L.DivIcon({
605
- html: `<div><span>${childCount}</span></div>`,
606
- className: `marker-cluster ${c}`,
607
- iconSize: new L.Point(40, 40)
311
+ _defaultIconCreateFunction: (t) => {
312
+ const e = t.getChildCount();
313
+ let i = " marker-cluster-";
314
+ return e < 10 ? i += "small" : e < 100 ? i += "medium" : i += "large", new u.DivIcon({
315
+ html: `<div><span>${e}</span></div>`,
316
+ className: `marker-cluster ${i}`,
317
+ iconSize: new u.Point(40, 40)
608
318
  });
609
319
  },
610
320
  _bindEvents: function() {
611
- var map = this._map, spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, showCoverageOnHover = this.options.showCoverageOnHover, zoomToBoundsOnClick = this.options.zoomToBoundsOnClick;
612
- if (spiderfyOnMaxZoom || zoomToBoundsOnClick) {
613
- this.on("clusterclick", this._zoomOrSpiderfy, this);
614
- }
615
- if (showCoverageOnHover) {
616
- this.on("clustermouseover", this._showCoverage, this);
617
- this.on("clustermouseout", this._hideCoverage, this);
618
- map.on("zoomend", this._hideCoverage, this);
619
- }
620
- },
621
- _zoomOrSpiderfy: function(e) {
622
- const cluster = e.propagatedFrom;
623
- let bottomCluster = cluster;
624
- while (bottomCluster._childClusters.length === 1) {
625
- bottomCluster = bottomCluster._childClusters[0];
626
- }
627
- if (bottomCluster._zoom === this._maxZoom && bottomCluster._childCount === cluster._childCount && this.options.spiderfyOnMaxZoom) {
628
- cluster.spiderfy();
629
- } else if (this.options.zoomToBoundsOnClick) {
630
- cluster.zoomToBounds();
631
- }
632
- if (e.originalEvent && e.originalEvent.keyCode === 13) {
633
- this._map._container.focus();
634
- }
635
- },
636
- _showCoverage: function(e) {
637
- var map = this._map;
638
- if (this._inZoomAnimation) {
639
- return;
640
- }
641
- if (this._shownPolygon) {
642
- map.removeLayer(this._shownPolygon);
643
- }
644
- if (e.propagatedFrom.getChildCount() > 2 && e.propagatedFrom !== this._spiderfied) {
645
- this._shownPolygon = new L.Polygon(
646
- e.propagatedFrom.getConvexHull(),
647
- this.options.polygonOptions
648
- );
649
- map.addLayer(this._shownPolygon);
650
- }
321
+ var t = this._map, e = this.options.spiderfyOnMaxZoom, i = this.options.showCoverageOnHover, n = this.options.zoomToBoundsOnClick;
322
+ (e || n) && this.on("clusterclick", this._zoomOrSpiderfy, this), i && (this.on("clustermouseover", this._showCoverage, this), this.on("clustermouseout", this._hideCoverage, this), t.on("zoomend", this._hideCoverage, this));
323
+ },
324
+ _zoomOrSpiderfy: function(t) {
325
+ const e = t.propagatedFrom;
326
+ let i = e;
327
+ for (; i._childClusters.length === 1; )
328
+ i = i._childClusters[0];
329
+ i._zoom === this._maxZoom && i._childCount === e._childCount && this.options.spiderfyOnMaxZoom ? e.spiderfy() : this.options.zoomToBoundsOnClick && e.zoomToBounds(), t.originalEvent && t.originalEvent.keyCode === 13 && this._map._container.focus();
330
+ },
331
+ _showCoverage: function(t) {
332
+ var e = this._map;
333
+ this._inZoomAnimation || (this._shownPolygon && e.removeLayer(this._shownPolygon), t.propagatedFrom.getChildCount() > 2 && t.propagatedFrom !== this._spiderfied && (this._shownPolygon = new u.Polygon(
334
+ t.propagatedFrom.getConvexHull(),
335
+ this.options.polygonOptions
336
+ ), e.addLayer(this._shownPolygon)));
651
337
  },
652
338
  _hideCoverage: function() {
653
- if (this._shownPolygon) {
654
- this._map.removeLayer(this._shownPolygon);
655
- this._shownPolygon = null;
656
- }
339
+ this._shownPolygon && (this._map.removeLayer(this._shownPolygon), this._shownPolygon = null);
657
340
  },
658
341
  _unbindEvents: function() {
659
- var spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, showCoverageOnHover = this.options.showCoverageOnHover, zoomToBoundsOnClick = this.options.zoomToBoundsOnClick, map = this._map;
660
- if (spiderfyOnMaxZoom || zoomToBoundsOnClick) {
661
- this.off("clusterclick", this._zoomOrSpiderfy, this);
662
- }
663
- if (showCoverageOnHover) {
664
- this.off("clustermouseover", this._showCoverage, this);
665
- this.off("clustermouseout", this._hideCoverage, this);
666
- map.off("zoomend", this._hideCoverage, this);
667
- }
342
+ var t = this.options.spiderfyOnMaxZoom, e = this.options.showCoverageOnHover, i = this.options.zoomToBoundsOnClick, n = this._map;
343
+ (t || i) && this.off("clusterclick", this._zoomOrSpiderfy, this), e && (this.off("clustermouseover", this._showCoverage, this), this.off("clustermouseout", this._hideCoverage, this), n.off("zoomend", this._hideCoverage, this));
668
344
  },
669
345
  _zoomEnd: function() {
670
- if (!this._map) {
671
- return;
672
- }
673
- this._mergeSplitClusters();
674
- this._zoom = Math.round(this._map._zoom);
675
- this._currentShownBounds = this._getExpandedVisibleBounds();
346
+ this._map && (this._mergeSplitClusters(), this._zoom = Math.round(this._map._zoom), this._currentShownBounds = this._getExpandedVisibleBounds());
676
347
  },
677
348
  _moveEnd: function() {
678
- if (this._inZoomAnimation) {
679
- return;
349
+ if (!this._inZoomAnimation) {
350
+ var t = this._getExpandedVisibleBounds();
351
+ this._topClusterLevel._recursivelyRemoveChildrenFromMap(
352
+ this._currentShownBounds,
353
+ Math.floor(this._map.getMinZoom()),
354
+ this._zoom,
355
+ t
356
+ ), this._topClusterLevel._recursivelyAddChildrenToMap(
357
+ null,
358
+ Math.round(this._map._zoom),
359
+ t
360
+ ), this._currentShownBounds = t;
680
361
  }
681
- var newBounds = this._getExpandedVisibleBounds();
682
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(
683
- this._currentShownBounds,
684
- Math.floor(this._map.getMinZoom()),
685
- this._zoom,
686
- newBounds
687
- );
688
- this._topClusterLevel._recursivelyAddChildrenToMap(
689
- null,
690
- Math.round(this._map._zoom),
691
- newBounds
692
- );
693
- this._currentShownBounds = newBounds;
694
- return;
695
362
  },
696
363
  _generateInitialClusters: function() {
697
- var maxZoom = Math.ceil(this._map.getMaxZoom()), minZoom = Math.floor(this._map.getMinZoom()), radius = this.options.maxClusterRadius, radiusFn = radius;
698
- if (typeof radius !== "function") {
699
- radiusFn = () => radius;
700
- }
701
- if (this.options.disableClusteringAtZoom !== null) {
702
- maxZoom = this.options.disableClusteringAtZoom - 1;
703
- }
704
- this._maxZoom = maxZoom;
705
- this._gridClusters = {};
706
- this._gridUnclustered = {};
707
- for (let zoom = maxZoom; zoom >= minZoom; zoom--) {
708
- this._gridClusters[zoom] = new L.DistanceGrid(radiusFn(zoom));
709
- this._gridUnclustered[zoom] = new L.DistanceGrid(radiusFn(zoom));
710
- }
711
- this._topClusterLevel = new this._markerCluster(this, minZoom - 1);
364
+ var t = Math.ceil(this._map.getMaxZoom()), e = Math.floor(this._map.getMinZoom()), i = this.options.maxClusterRadius, n = i;
365
+ typeof i != "function" && (n = () => i), this.options.disableClusteringAtZoom !== null && (t = this.options.disableClusteringAtZoom - 1), this._maxZoom = t, this._gridClusters = {}, this._gridUnclustered = {};
366
+ for (let s = t; s >= e; s--)
367
+ this._gridClusters[s] = new u.DistanceGrid(n(s)), this._gridUnclustered[s] = new u.DistanceGrid(n(s));
368
+ this._topClusterLevel = new this._markerCluster(this, e - 1);
712
369
  },
713
370
  //Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)
714
- _addLayer: function(layer, zoom) {
715
- var gridClusters = this._gridClusters, gridUnclustered = this._gridUnclustered, minZoom = Math.floor(this._map.getMinZoom()), markerPoint, z;
716
- if (this.options.singleMarkerMode) {
717
- this._overrideMarkerIcon(layer);
718
- }
719
- layer.on(this._childMarkerEventHandlers, this);
720
- for (; zoom >= minZoom; zoom--) {
721
- markerPoint = this._map.project(layer.getLatLng(), zoom);
722
- let closest = gridClusters[zoom].getNearObject(markerPoint);
723
- if (closest) {
724
- closest._addChild(layer);
725
- layer.__parent = closest;
371
+ _addLayer: function(t, e) {
372
+ var i = this._gridClusters, n = this._gridUnclustered, s = Math.floor(this._map.getMinZoom()), o, r;
373
+ for (this.options.singleMarkerMode && this._overrideMarkerIcon(t), t.on(this._childMarkerEventHandlers, this); e >= s; e--) {
374
+ o = this._map.project(t.getLatLng(), e);
375
+ let a = i[e].getNearObject(o);
376
+ if (a) {
377
+ a._addChild(t), t.__parent = a;
726
378
  return;
727
379
  }
728
- closest = gridUnclustered[zoom].getNearObject(markerPoint);
729
- if (closest) {
730
- const parent = closest.__parent;
731
- if (parent) {
732
- this._removeLayer(closest, false);
733
- }
734
- const newCluster = new this._markerCluster(this, zoom, closest, layer);
735
- gridClusters[zoom].addObject(
736
- newCluster,
737
- this._map.project(newCluster._cLatLng, zoom)
738
- );
739
- closest.__parent = newCluster;
740
- layer.__parent = newCluster;
741
- let lastParent = newCluster;
742
- for (z = zoom - 1; z > parent._zoom; z--) {
743
- lastParent = new this._markerCluster(this, z, lastParent);
744
- gridClusters[z].addObject(
745
- lastParent,
746
- this._map.project(closest.getLatLng(), z)
380
+ if (a = n[e].getNearObject(o), a) {
381
+ const h = a.__parent;
382
+ h && this._removeLayer(a, !1);
383
+ const _ = new this._markerCluster(this, e, a, t);
384
+ i[e].addObject(
385
+ _,
386
+ this._map.project(_._cLatLng, e)
387
+ ), a.__parent = _, t.__parent = _;
388
+ let l = _;
389
+ for (r = e - 1; r > h._zoom; r--)
390
+ l = new this._markerCluster(this, r, l), i[r].addObject(
391
+ l,
392
+ this._map.project(a.getLatLng(), r)
747
393
  );
748
- }
749
- parent._addChild(lastParent);
750
- this._removeFromGridUnclustered(closest, zoom);
394
+ h._addChild(l), this._removeFromGridUnclustered(a, e);
751
395
  return;
752
396
  }
753
- gridUnclustered[zoom].addObject(layer, markerPoint);
397
+ n[e].addObject(t, o);
754
398
  }
755
- this._topClusterLevel._addChild(layer);
756
- layer.__parent = this._topClusterLevel;
757
- return;
399
+ this._topClusterLevel._addChild(t), t.__parent = this._topClusterLevel;
758
400
  },
759
401
  /**
760
402
  * Refreshes the icon of all "dirty" visible clusters.
@@ -762,54 +404,35 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
762
404
  * @private
763
405
  */
764
406
  _refreshClustersIcons: function() {
765
- this._featureGroup.eachLayer((c) => {
766
- if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
767
- c._updateIcon();
768
- }
407
+ this._featureGroup.eachLayer((t) => {
408
+ t instanceof u.MarkerCluster && t._iconNeedsUpdate && t._updateIcon();
769
409
  });
770
410
  },
771
411
  //Enqueue code to fire after the marker expand/contract has happened
772
- _enqueue: function(fn) {
773
- this._queue.push(fn);
774
- if (!this._queueTimeout) {
775
- this._queueTimeout = setTimeout(() => this._processQueue(), 300);
776
- }
412
+ _enqueue: function(t) {
413
+ this._queue.push(t), this._queueTimeout || (this._queueTimeout = setTimeout(() => this._processQueue(), 300));
777
414
  },
778
415
  _processQueue: function() {
779
- for (let i = 0; i < this._queue.length; i++) {
780
- this._queue[i].call(this);
781
- }
782
- this._queue.length = 0;
783
- clearTimeout(this._queueTimeout);
784
- this._queueTimeout = null;
416
+ for (let t = 0; t < this._queue.length; t++)
417
+ this._queue[t].call(this);
418
+ this._queue.length = 0, clearTimeout(this._queueTimeout), this._queueTimeout = null;
785
419
  },
786
420
  //Merge and split any existing clusters that are too big or small
787
421
  _mergeSplitClusters: function() {
788
- var mapZoom = Math.round(this._map._zoom);
789
- this._processQueue();
790
- if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) {
791
- this._animationStart();
792
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(
793
- this._currentShownBounds,
794
- Math.floor(this._map.getMinZoom()),
795
- this._zoom,
796
- this._getExpandedVisibleBounds()
797
- );
798
- this._animationZoomIn(this._zoom, mapZoom);
799
- } else if (this._zoom > mapZoom) {
800
- this._animationStart();
801
- this._animationZoomOut(this._zoom, mapZoom);
802
- } else {
803
- this._moveEnd();
804
- }
422
+ var t = Math.round(this._map._zoom);
423
+ this._processQueue(), this._zoom < t && this._currentShownBounds.intersects(this._getExpandedVisibleBounds()) ? (this._animationStart(), this._topClusterLevel._recursivelyRemoveChildrenFromMap(
424
+ this._currentShownBounds,
425
+ Math.floor(this._map.getMinZoom()),
426
+ this._zoom,
427
+ this._getExpandedVisibleBounds()
428
+ ), this._animationZoomIn(this._zoom, t)) : this._zoom > t ? (this._animationStart(), this._animationZoomOut(this._zoom, t)) : this._moveEnd();
805
429
  },
806
430
  //Gets the maps visible bounds expanded in each direction by the size of the screen (so the user cannot see an area we do not cover in one pan)
807
431
  _getExpandedVisibleBounds: function() {
808
- if (!this.options.removeOutsideVisibleBounds) {
809
- return this._mapBoundsInfinite;
810
- } else if (L.Browser.mobile) {
811
- return this._checkBoundsMaxLat(this._map.getBounds());
812
- }
432
+ if (this.options.removeOutsideVisibleBounds) {
433
+ if (u.Browser.mobile)
434
+ return this._checkBoundsMaxLat(this._map.getBounds());
435
+ } else return this._mapBoundsInfinite;
813
436
  return this._checkBoundsMaxLat(this._map.getBounds().pad(1));
814
437
  },
815
438
  /**
@@ -822,30 +445,20 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
822
445
  * @returns {L.LatLngBounds}
823
446
  * @private
824
447
  */
825
- _checkBoundsMaxLat: function(bounds) {
826
- var maxLat = this._maxLat;
827
- if (maxLat !== void 0) {
828
- if (bounds.getNorth() >= maxLat) {
829
- bounds._northEast.lat = Infinity;
830
- }
831
- if (bounds.getSouth() <= -maxLat) {
832
- bounds._southWest.lat = -Infinity;
833
- }
834
- }
835
- return bounds;
448
+ _checkBoundsMaxLat: function(t) {
449
+ var e = this._maxLat;
450
+ return e !== void 0 && (t.getNorth() >= e && (t._northEast.lat = 1 / 0), t.getSouth() <= -e && (t._southWest.lat = -1 / 0)), t;
836
451
  },
837
452
  //Shared animation code
838
- _animationAddLayerNonAnimated: function(layer, newCluster) {
839
- if (newCluster === layer) {
840
- this._featureGroup.addLayer(layer);
841
- } else if (newCluster._childCount === 2) {
842
- newCluster._addToMap();
843
- const markers = newCluster.getAllChildMarkers();
844
- this._featureGroup.removeLayer(markers[0]);
845
- this._featureGroup.removeLayer(markers[1]);
846
- } else {
847
- newCluster._updateIcon();
848
- }
453
+ _animationAddLayerNonAnimated: function(t, e) {
454
+ if (e === t)
455
+ this._featureGroup.addLayer(t);
456
+ else if (e._childCount === 2) {
457
+ e._addToMap();
458
+ const i = e.getAllChildMarkers();
459
+ this._featureGroup.removeLayer(i[0]), this._featureGroup.removeLayer(i[1]);
460
+ } else
461
+ e._updateIcon();
849
462
  },
850
463
  /**
851
464
  * Extracts individual (i.e. non-group) layers from a Layer Group.
@@ -854,18 +467,16 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
854
467
  * @returns {*|Array}
855
468
  * @private
856
469
  */
857
- _extractNonGroupLayers: function(group, output) {
858
- var layers = group.getLayers(), i = 0, layer;
859
- output = output || [];
860
- for (; i < layers.length; i++) {
861
- layer = layers[i];
862
- if (layer instanceof L.LayerGroup) {
863
- this._extractNonGroupLayers(layer, output);
470
+ _extractNonGroupLayers: function(t, e) {
471
+ var i = t.getLayers(), n = 0, s;
472
+ for (e = e || []; n < i.length; n++) {
473
+ if (s = i[n], s instanceof u.LayerGroup) {
474
+ this._extractNonGroupLayers(s, e);
864
475
  continue;
865
476
  }
866
- output.push(layer);
477
+ e.push(s);
867
478
  }
868
- return output;
479
+ return e;
869
480
  },
870
481
  /**
871
482
  * Implements the singleMarkerMode option.
@@ -873,318 +484,206 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
873
484
  * @returns {L.Icon} The newly created icon.
874
485
  * @private
875
486
  */
876
- _overrideMarkerIcon: function(layer) {
877
- layer.options.icon = this.options.iconCreateFunction({
487
+ _overrideMarkerIcon: function(t) {
488
+ return t.options.icon = this.options.iconCreateFunction({
878
489
  getChildCount: () => 1,
879
- getAllChildMarkers: () => [layer]
880
- });
881
- return layer.options.icon;
490
+ getAllChildMarkers: () => [t]
491
+ }), t.options.icon;
882
492
  }
883
493
  });
884
- L.MarkerClusterGroup.include({
885
- _mapBoundsInfinite: new L.LatLngBounds(
886
- new L.LatLng(-Infinity, -Infinity),
887
- new L.LatLng(Infinity, Infinity)
494
+ u.MarkerClusterGroup.include({
495
+ _mapBoundsInfinite: new u.LatLngBounds(
496
+ new u.LatLng(-1 / 0, -1 / 0),
497
+ new u.LatLng(1 / 0, 1 / 0)
888
498
  )
889
499
  });
890
- L.MarkerClusterGroup.include({
500
+ u.MarkerClusterGroup.include({
891
501
  _noAnimation: {
892
502
  //Non Animated versions of everything
893
503
  _animationStart: () => {
894
504
  },
895
- _animationZoomIn: function(previousZoomLevel, newZoomLevel) {
505
+ _animationZoomIn: function(t, e) {
896
506
  this._topClusterLevel._recursivelyRemoveChildrenFromMap(
897
507
  this._currentShownBounds,
898
508
  Math.floor(this._map.getMinZoom()),
899
- previousZoomLevel
900
- );
901
- this._topClusterLevel._recursivelyAddChildrenToMap(
509
+ t
510
+ ), this._topClusterLevel._recursivelyAddChildrenToMap(
902
511
  null,
903
- newZoomLevel,
512
+ e,
904
513
  this._getExpandedVisibleBounds()
905
- );
906
- this.fire("animationend");
514
+ ), this.fire("animationend");
907
515
  },
908
- _animationZoomOut: function(previousZoomLevel, newZoomLevel) {
516
+ _animationZoomOut: function(t, e) {
909
517
  this._topClusterLevel._recursivelyRemoveChildrenFromMap(
910
518
  this._currentShownBounds,
911
519
  Math.floor(this._map.getMinZoom()),
912
- previousZoomLevel
913
- );
914
- this._topClusterLevel._recursivelyAddChildrenToMap(
520
+ t
521
+ ), this._topClusterLevel._recursivelyAddChildrenToMap(
915
522
  null,
916
- newZoomLevel,
523
+ e,
917
524
  this._getExpandedVisibleBounds()
918
- );
919
- this.fire("animationend");
525
+ ), this.fire("animationend");
920
526
  },
921
- _animationAddLayer: function(layer, newCluster) {
922
- this._animationAddLayerNonAnimated(layer, newCluster);
527
+ _animationAddLayer: function(t, e) {
528
+ this._animationAddLayerNonAnimated(t, e);
923
529
  }
924
530
  },
925
531
  _withAnimation: {
926
532
  //Animated versions here
927
533
  _animationStart: function() {
928
- this._map._mapPane.className += " leaflet-cluster-anim";
929
- this._inZoomAnimation++;
534
+ this._map._mapPane.className += " leaflet-cluster-anim", this._inZoomAnimation++;
930
535
  },
931
- _animationZoomIn: function(previousZoomLevel, newZoomLevel) {
932
- var bounds = this._getExpandedVisibleBounds(), fg = this._featureGroup, minZoom = Math.floor(this._map.getMinZoom()), i;
933
- this._ignoreMove = true;
934
- this._topClusterLevel._recursively(
935
- bounds,
936
- previousZoomLevel,
937
- minZoom,
938
- (c) => {
939
- var startPos = c._latlng, markers = c._markers, m;
940
- if (!bounds.contains(startPos)) {
941
- startPos = null;
942
- }
943
- if (c._isSingleParent() && previousZoomLevel + 1 === newZoomLevel) {
944
- fg.removeLayer(c);
945
- c._recursivelyAddChildrenToMap(null, newZoomLevel, bounds);
946
- } else {
947
- c.clusterHide();
948
- c._recursivelyAddChildrenToMap(startPos, newZoomLevel, bounds);
949
- }
950
- for (i = markers.length - 1; i >= 0; i--) {
951
- m = markers[i];
952
- if (!bounds.contains(m._latlng)) {
953
- fg.removeLayer(m);
954
- }
955
- }
536
+ _animationZoomIn: function(t, e) {
537
+ var i = this._getExpandedVisibleBounds(), n = this._featureGroup, s = Math.floor(this._map.getMinZoom()), o;
538
+ this._ignoreMove = !0, this._topClusterLevel._recursively(
539
+ i,
540
+ t,
541
+ s,
542
+ (r) => {
543
+ var a = r._latlng, h = r._markers, _;
544
+ for (i.contains(a) || (a = null), r._isSingleParent() && t + 1 === e ? (n.removeLayer(r), r._recursivelyAddChildrenToMap(null, e, i)) : (r.clusterHide(), r._recursivelyAddChildrenToMap(a, e, i)), o = h.length - 1; o >= 0; o--)
545
+ _ = h[o], i.contains(_._latlng) || n.removeLayer(_);
956
546
  }
957
- );
958
- this._forceLayout();
959
- this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel);
960
- fg.eachLayer((n) => {
961
- if (!(n instanceof L.MarkerCluster) && n._icon) {
962
- n.clusterShow();
547
+ ), this._forceLayout(), this._topClusterLevel._recursivelyBecomeVisible(i, e), n.eachLayer((r) => {
548
+ !(r instanceof u.MarkerCluster) && r._icon && r.clusterShow();
549
+ }), this._topClusterLevel._recursively(
550
+ i,
551
+ t,
552
+ e,
553
+ (r) => {
554
+ r._recursivelyRestoreChildPositions(e);
963
555
  }
964
- });
965
- this._topClusterLevel._recursively(
966
- bounds,
967
- previousZoomLevel,
968
- newZoomLevel,
969
- (c) => {
970
- c._recursivelyRestoreChildPositions(newZoomLevel);
971
- }
972
- );
973
- this._ignoreMove = false;
974
- this._enqueue(function() {
556
+ ), this._ignoreMove = !1, this._enqueue(function() {
975
557
  this._topClusterLevel._recursively(
976
- bounds,
977
- previousZoomLevel,
978
- minZoom,
979
- (c) => {
980
- fg.removeLayer(c);
981
- c.clusterShow();
558
+ i,
559
+ t,
560
+ s,
561
+ (r) => {
562
+ n.removeLayer(r), r.clusterShow();
982
563
  }
983
- );
984
- this._animationEnd();
564
+ ), this._animationEnd();
985
565
  });
986
566
  },
987
- _animationZoomOut: function(previousZoomLevel, newZoomLevel) {
567
+ _animationZoomOut: function(t, e) {
988
568
  this._animationZoomOutSingle(
989
569
  this._topClusterLevel,
990
- previousZoomLevel - 1,
991
- newZoomLevel
992
- );
993
- this._topClusterLevel._recursivelyAddChildrenToMap(
570
+ t - 1,
571
+ e
572
+ ), this._topClusterLevel._recursivelyAddChildrenToMap(
994
573
  null,
995
- newZoomLevel,
574
+ e,
996
575
  this._getExpandedVisibleBounds()
997
- );
998
- this._topClusterLevel._recursivelyRemoveChildrenFromMap(
576
+ ), this._topClusterLevel._recursivelyRemoveChildrenFromMap(
999
577
  this._currentShownBounds,
1000
578
  Math.floor(this._map.getMinZoom()),
1001
- previousZoomLevel,
579
+ t,
1002
580
  this._getExpandedVisibleBounds()
1003
581
  );
1004
582
  },
1005
- _animationAddLayer: function(layer, newCluster) {
1006
- var fg = this._featureGroup;
1007
- fg.addLayer(layer);
1008
- if (newCluster !== layer) {
1009
- if (newCluster._childCount > 2) {
1010
- newCluster._updateIcon();
1011
- this._forceLayout();
1012
- this._animationStart();
1013
- layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng()));
1014
- layer.clusterHide();
1015
- this._enqueue(() => {
1016
- fg.removeLayer(layer);
1017
- layer.clusterShow();
1018
- this._animationEnd();
1019
- });
1020
- } else {
1021
- this._forceLayout();
1022
- this._animationStart();
1023
- this._animationZoomOutSingle(
1024
- newCluster,
1025
- this._map.getMaxZoom(),
1026
- this._zoom
1027
- );
1028
- }
1029
- }
583
+ _animationAddLayer: function(t, e) {
584
+ var i = this._featureGroup;
585
+ i.addLayer(t), e !== t && (e._childCount > 2 ? (e._updateIcon(), this._forceLayout(), this._animationStart(), t._setPos(this._map.latLngToLayerPoint(e.getLatLng())), t.clusterHide(), this._enqueue(() => {
586
+ i.removeLayer(t), t.clusterShow(), this._animationEnd();
587
+ })) : (this._forceLayout(), this._animationStart(), this._animationZoomOutSingle(
588
+ e,
589
+ this._map.getMaxZoom(),
590
+ this._zoom
591
+ )));
1030
592
  }
1031
593
  },
1032
594
  // Private methods for animated versions.
1033
- _animationZoomOutSingle: function(cluster, previousZoomLevel, newZoomLevel) {
1034
- var bounds = this._getExpandedVisibleBounds(), minZoom = Math.floor(this._map.getMinZoom());
1035
- cluster._recursivelyAnimateChildrenInAndAddSelfToMap(
1036
- bounds,
1037
- minZoom,
1038
- previousZoomLevel + 1,
1039
- newZoomLevel
595
+ _animationZoomOutSingle: function(t, e, i) {
596
+ var n = this._getExpandedVisibleBounds(), s = Math.floor(this._map.getMinZoom());
597
+ t._recursivelyAnimateChildrenInAndAddSelfToMap(
598
+ n,
599
+ s,
600
+ e + 1,
601
+ i
1040
602
  );
1041
- var me = this;
1042
- this._forceLayout();
1043
- cluster._recursivelyBecomeVisible(bounds, newZoomLevel);
1044
- this._enqueue(function() {
1045
- if (cluster._childCount === 1) {
1046
- const m = cluster._markers[0];
1047
- this._ignoreMove = true;
1048
- m.setLatLng(m.getLatLng());
1049
- this._ignoreMove = false;
1050
- if (m.clusterShow) {
1051
- m.clusterShow();
1052
- }
1053
- } else {
1054
- cluster._recursively(bounds, newZoomLevel, minZoom, (c) => {
1055
- c._recursivelyRemoveChildrenFromMap(
1056
- bounds,
1057
- minZoom,
1058
- previousZoomLevel + 1
603
+ var o = this;
604
+ this._forceLayout(), t._recursivelyBecomeVisible(n, i), this._enqueue(function() {
605
+ if (t._childCount === 1) {
606
+ const r = t._markers[0];
607
+ this._ignoreMove = !0, r.setLatLng(r.getLatLng()), this._ignoreMove = !1, r.clusterShow && r.clusterShow();
608
+ } else
609
+ t._recursively(n, i, s, (r) => {
610
+ r._recursivelyRemoveChildrenFromMap(
611
+ n,
612
+ s,
613
+ e + 1
1059
614
  );
1060
615
  });
1061
- }
1062
- me._animationEnd();
616
+ o._animationEnd();
1063
617
  });
1064
618
  },
1065
619
  _animationEnd: function() {
1066
- if (this._map) {
1067
- this._map._mapPane.className = this._map._mapPane.className.replace(
1068
- " leaflet-cluster-anim",
1069
- ""
1070
- );
1071
- }
1072
- this._inZoomAnimation--;
1073
- this.fire("animationend");
620
+ this._map && (this._map._mapPane.className = this._map._mapPane.className.replace(
621
+ " leaflet-cluster-anim",
622
+ ""
623
+ )), this._inZoomAnimation--, this.fire("animationend");
1074
624
  },
1075
625
  //Force a browser layout of stuff in the map
1076
626
  // Should apply the current opacity and location to all elements so we can update them again for an animation
1077
627
  _forceLayout: () => {
1078
- L.Util.falseFn(document.body.offsetWidth);
628
+ u.Util.falseFn(document.body.offsetWidth);
1079
629
  }
1080
630
  });
1081
- L.MarkerCluster = L.Marker.extend({
1082
- initialize: function(group, zoom, a, b) {
1083
- L.Marker.prototype.initialize.call(
631
+ u.MarkerCluster = u.Marker.extend({
632
+ initialize: function(t, e, i, n) {
633
+ u.Marker.prototype.initialize.call(
1084
634
  this,
1085
- a ? a._cLatLng || a.getLatLng() : new L.LatLng(0, 0),
1086
- { icon: this, pane: group.options.clusterPane }
1087
- );
1088
- this._group = group;
1089
- this._zoom = zoom;
1090
- this._markers = [];
1091
- this._childClusters = [];
1092
- this._childCount = 0;
1093
- this._iconNeedsUpdate = true;
1094
- this._boundsNeedUpdate = true;
1095
- this._bounds = new L.LatLngBounds();
1096
- if (a) {
1097
- this._addChild(a);
1098
- }
1099
- if (b) {
1100
- this._addChild(b);
1101
- }
635
+ i ? i._cLatLng || i.getLatLng() : new u.LatLng(0, 0),
636
+ { icon: this, pane: t.options.clusterPane }
637
+ ), this._group = t, this._zoom = e, this._markers = [], this._childClusters = [], this._childCount = 0, this._iconNeedsUpdate = !0, this._boundsNeedUpdate = !0, this._bounds = new u.LatLngBounds(), i && this._addChild(i), n && this._addChild(n);
1102
638
  },
1103
639
  //Recursively retrieve all child markers of this cluster
1104
- getAllChildMarkers: function(storageArray) {
1105
- storageArray = storageArray || [];
1106
- for (let i = this._childClusters.length - 1; i >= 0; i--) {
1107
- this._childClusters[i].getAllChildMarkers(storageArray);
1108
- }
1109
- for (let j = this._markers.length - 1; j >= 0; j--) {
1110
- storageArray.push(this._markers[j]);
1111
- }
1112
- return storageArray;
640
+ getAllChildMarkers: function(t) {
641
+ t = t || [];
642
+ for (let e = this._childClusters.length - 1; e >= 0; e--)
643
+ this._childClusters[e].getAllChildMarkers(t);
644
+ for (let e = this._markers.length - 1; e >= 0; e--)
645
+ t.push(this._markers[e]);
646
+ return t;
1113
647
  },
1114
648
  //Returns the count of how many child markers we have
1115
649
  getChildCount: function() {
1116
650
  return this._childCount;
1117
651
  },
1118
652
  //Zoom to the minimum of showing all of the child markers, or the extents of this cluster
1119
- zoomToBounds: function(fitBoundsOptions) {
1120
- var childClusters = this._childClusters.slice(), map = this._group._map, boundsZoom = map.getBoundsZoom(this._bounds), zoom = this._zoom + 1, mapZoom = map.getZoom(), i;
1121
- while (childClusters.length > 0 && boundsZoom > zoom) {
1122
- zoom++;
1123
- let newClusters = [];
1124
- for (i = 0; i < childClusters.length; i++) {
1125
- newClusters = newClusters.concat(childClusters[i]._childClusters);
1126
- }
1127
- childClusters = newClusters;
1128
- }
1129
- if (boundsZoom > zoom) {
1130
- this._group._map.setView(this._latlng, zoom);
1131
- } else if (boundsZoom <= mapZoom) {
1132
- this._group._map.setView(this._latlng, mapZoom + 1);
1133
- } else {
1134
- this._group._map.fitBounds(this._bounds, fitBoundsOptions);
653
+ zoomToBounds: function(t) {
654
+ for (var e = this._childClusters.slice(), i = this._group._map, n = i.getBoundsZoom(this._bounds), s = this._zoom + 1, o = i.getZoom(), r; e.length > 0 && n > s; ) {
655
+ s++;
656
+ let a = [];
657
+ for (r = 0; r < e.length; r++)
658
+ a = a.concat(e[r]._childClusters);
659
+ e = a;
1135
660
  }
661
+ n > s ? this._group._map.setView(this._latlng, s) : n <= o ? this._group._map.setView(this._latlng, o + 1) : this._group._map.fitBounds(this._bounds, t);
1136
662
  },
1137
663
  getBounds: function() {
1138
- var bounds = new L.LatLngBounds();
1139
- bounds.extend(this._bounds);
1140
- return bounds;
664
+ var t = new u.LatLngBounds();
665
+ return t.extend(this._bounds), t;
1141
666
  },
1142
667
  _updateIcon: function() {
1143
- this._iconNeedsUpdate = true;
1144
- if (this._icon) {
1145
- this.setIcon(this);
1146
- }
668
+ this._iconNeedsUpdate = !0, this._icon && this.setIcon(this);
1147
669
  },
1148
670
  //Cludge for Icon, we pretend to be an icon for performance
1149
671
  createIcon: function() {
1150
- if (this._iconNeedsUpdate) {
1151
- this._iconObj = this._group.options.iconCreateFunction(this);
1152
- this._iconNeedsUpdate = false;
1153
- }
1154
- return this._iconObj.createIcon();
672
+ return this._iconNeedsUpdate && (this._iconObj = this._group.options.iconCreateFunction(this), this._iconNeedsUpdate = !1), this._iconObj.createIcon();
1155
673
  },
1156
674
  createShadow: function() {
1157
675
  return this._iconObj.createShadow();
1158
676
  },
1159
- _addChild: function(new1, isNotificationFromChild) {
1160
- this._iconNeedsUpdate = true;
1161
- this._boundsNeedUpdate = true;
1162
- this._setClusterCenter(new1);
1163
- if (new1 instanceof L.MarkerCluster) {
1164
- if (!isNotificationFromChild) {
1165
- this._childClusters.push(new1);
1166
- new1.__parent = this;
1167
- }
1168
- this._childCount += new1._childCount;
1169
- } else {
1170
- if (!isNotificationFromChild) {
1171
- this._markers.push(new1);
1172
- }
1173
- this._childCount++;
1174
- }
1175
- if (this.__parent) {
1176
- this.__parent._addChild(new1, true);
1177
- }
677
+ _addChild: function(t, e) {
678
+ this._iconNeedsUpdate = !0, this._boundsNeedUpdate = !0, this._setClusterCenter(t), t instanceof u.MarkerCluster ? (e || (this._childClusters.push(t), t.__parent = this), this._childCount += t._childCount) : (e || this._markers.push(t), this._childCount++), this.__parent && this.__parent._addChild(t, !0);
1178
679
  },
1179
680
  /**
1180
681
  * Makes sure the cluster center is set. If not, uses the child center if it is a cluster, or the marker position.
1181
682
  * @param child L.MarkerCluster|L.Marker that will be used as cluster center if not defined yet.
1182
683
  * @private
1183
684
  */
1184
- _setClusterCenter: function(child) {
1185
- if (!this._cLatLng) {
1186
- this._cLatLng = child._cLatLng || child._latlng;
1187
- }
685
+ _setClusterCenter: function(t) {
686
+ this._cLatLng || (this._cLatLng = t._cLatLng || t._latlng);
1188
687
  },
1189
688
  /**
1190
689
  * Assigns impossible bounding values so that the next extend entirely determines the new bounds.
@@ -1193,192 +692,113 @@ L.MarkerCluster = L.Marker.extend({
1193
692
  * @private
1194
693
  */
1195
694
  _resetBounds: function() {
1196
- var bounds = this._bounds;
1197
- if (bounds._southWest) {
1198
- bounds._southWest.lat = Infinity;
1199
- bounds._southWest.lng = Infinity;
1200
- }
1201
- if (bounds._northEast) {
1202
- bounds._northEast.lat = -Infinity;
1203
- bounds._northEast.lng = -Infinity;
1204
- }
695
+ var t = this._bounds;
696
+ t._southWest && (t._southWest.lat = 1 / 0, t._southWest.lng = 1 / 0), t._northEast && (t._northEast.lat = -1 / 0, t._northEast.lng = -1 / 0);
1205
697
  },
1206
698
  _recalculateBounds: function() {
1207
- var markers = this._markers, childClusters = this._childClusters, latSum = 0, lngSum = 0, totalCount = this._childCount, i, child, childLatLng, childCount;
1208
- if (totalCount === 0) {
1209
- return;
699
+ var t = this._markers, e = this._childClusters, i = 0, n = 0, s = this._childCount, o, r, a, h;
700
+ if (s !== 0) {
701
+ for (this._resetBounds(), o = 0; o < t.length; o++)
702
+ a = t[o]._latlng, this._bounds.extend(a), i += a.lat, n += a.lng;
703
+ for (o = 0; o < e.length; o++)
704
+ r = e[o], r._boundsNeedUpdate && r._recalculateBounds(), this._bounds.extend(r._bounds), a = r._wLatLng, h = r._childCount, i += a.lat * h, n += a.lng * h;
705
+ this._latlng = this._wLatLng = new u.LatLng(
706
+ i / s,
707
+ n / s
708
+ ), this._boundsNeedUpdate = !1;
1210
709
  }
1211
- this._resetBounds();
1212
- for (i = 0; i < markers.length; i++) {
1213
- childLatLng = markers[i]._latlng;
1214
- this._bounds.extend(childLatLng);
1215
- latSum += childLatLng.lat;
1216
- lngSum += childLatLng.lng;
1217
- }
1218
- for (i = 0; i < childClusters.length; i++) {
1219
- child = childClusters[i];
1220
- if (child._boundsNeedUpdate) {
1221
- child._recalculateBounds();
1222
- }
1223
- this._bounds.extend(child._bounds);
1224
- childLatLng = child._wLatLng;
1225
- childCount = child._childCount;
1226
- latSum += childLatLng.lat * childCount;
1227
- lngSum += childLatLng.lng * childCount;
1228
- }
1229
- this._latlng = this._wLatLng = new L.LatLng(
1230
- latSum / totalCount,
1231
- lngSum / totalCount
1232
- );
1233
- this._boundsNeedUpdate = false;
1234
710
  },
1235
711
  //Set our markers position as given and add it to the map
1236
- _addToMap: function(startPos) {
1237
- if (startPos) {
1238
- this._backupLatlng = this._latlng;
1239
- this.setLatLng(startPos);
1240
- }
1241
- this._group._featureGroup.addLayer(this);
712
+ _addToMap: function(t) {
713
+ t && (this._backupLatlng = this._latlng, this.setLatLng(t)), this._group._featureGroup.addLayer(this);
1242
714
  },
1243
- _recursivelyAnimateChildrenIn: function(bounds, center, maxZoom) {
715
+ _recursivelyAnimateChildrenIn: function(t, e, i) {
1244
716
  this._recursively(
1245
- bounds,
717
+ t,
1246
718
  this._group._map.getMinZoom(),
1247
- maxZoom - 1,
1248
- (c) => {
1249
- var markers = c._markers, i, m;
1250
- for (i = markers.length - 1; i >= 0; i--) {
1251
- m = markers[i];
1252
- if (m._icon) {
1253
- m._setPos(center);
1254
- m.clusterHide();
1255
- }
1256
- }
719
+ i - 1,
720
+ (n) => {
721
+ var s = n._markers, o, r;
722
+ for (o = s.length - 1; o >= 0; o--)
723
+ r = s[o], r._icon && (r._setPos(e), r.clusterHide());
1257
724
  },
1258
- (c) => {
1259
- var childClusters = c._childClusters, j, cm;
1260
- for (j = childClusters.length - 1; j >= 0; j--) {
1261
- cm = childClusters[j];
1262
- if (cm._icon) {
1263
- cm._setPos(center);
1264
- cm.clusterHide();
1265
- }
1266
- }
725
+ (n) => {
726
+ var s = n._childClusters, o, r;
727
+ for (o = s.length - 1; o >= 0; o--)
728
+ r = s[o], r._icon && (r._setPos(e), r.clusterHide());
1267
729
  }
1268
730
  );
1269
731
  },
1270
- _recursivelyAnimateChildrenInAndAddSelfToMap: function(bounds, mapMinZoom, previousZoomLevel, newZoomLevel) {
1271
- this._recursively(bounds, newZoomLevel, mapMinZoom, (c) => {
1272
- c._recursivelyAnimateChildrenIn(
1273
- bounds,
1274
- c._group._map.latLngToLayerPoint(c.getLatLng()).round(),
1275
- previousZoomLevel
1276
- );
1277
- if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) {
1278
- c.clusterShow();
1279
- c._recursivelyRemoveChildrenFromMap(
1280
- bounds,
1281
- mapMinZoom,
1282
- previousZoomLevel
1283
- );
1284
- } else {
1285
- c.clusterHide();
1286
- }
1287
- c._addToMap();
732
+ _recursivelyAnimateChildrenInAndAddSelfToMap: function(t, e, i, n) {
733
+ this._recursively(t, n, e, (s) => {
734
+ s._recursivelyAnimateChildrenIn(
735
+ t,
736
+ s._group._map.latLngToLayerPoint(s.getLatLng()).round(),
737
+ i
738
+ ), s._isSingleParent() && i - 1 === n ? (s.clusterShow(), s._recursivelyRemoveChildrenFromMap(
739
+ t,
740
+ e,
741
+ i
742
+ )) : s.clusterHide(), s._addToMap();
1288
743
  });
1289
744
  },
1290
- _recursivelyBecomeVisible: function(bounds, zoomLevel) {
745
+ _recursivelyBecomeVisible: function(t, e) {
1291
746
  this._recursively(
1292
- bounds,
747
+ t,
1293
748
  this._group._map.getMinZoom(),
1294
- zoomLevel,
749
+ e,
1295
750
  null,
1296
- (c) => {
1297
- c.clusterShow();
751
+ (i) => {
752
+ i.clusterShow();
1298
753
  }
1299
754
  );
1300
755
  },
1301
- _recursivelyAddChildrenToMap: function(startPos, zoomLevel, bounds) {
756
+ _recursivelyAddChildrenToMap: function(t, e, i) {
1302
757
  this._recursively(
1303
- bounds,
758
+ i,
1304
759
  this._group._map.getMinZoom() - 1,
1305
- zoomLevel,
1306
- (c) => {
1307
- if (zoomLevel === c._zoom) {
1308
- return;
1309
- }
1310
- for (let i = c._markers.length - 1; i >= 0; i--) {
1311
- const nm = c._markers[i];
1312
- if (!bounds.contains(nm._latlng)) {
1313
- continue;
1314
- }
1315
- if (startPos) {
1316
- nm._backupLatlng = nm.getLatLng();
1317
- nm.setLatLng(startPos);
1318
- if (nm.clusterHide) {
1319
- nm.clusterHide();
1320
- }
760
+ e,
761
+ (n) => {
762
+ if (e !== n._zoom)
763
+ for (let s = n._markers.length - 1; s >= 0; s--) {
764
+ const o = n._markers[s];
765
+ i.contains(o._latlng) && (t && (o._backupLatlng = o.getLatLng(), o.setLatLng(t), o.clusterHide && o.clusterHide()), n._group._featureGroup.addLayer(o));
1321
766
  }
1322
- c._group._featureGroup.addLayer(nm);
1323
- }
1324
767
  },
1325
- (c) => {
1326
- c._addToMap(startPos);
768
+ (n) => {
769
+ n._addToMap(t);
1327
770
  }
1328
771
  );
1329
772
  },
1330
- _recursivelyRestoreChildPositions: function(zoomLevel) {
1331
- for (let i = this._markers.length - 1; i >= 0; i--) {
1332
- const nm = this._markers[i];
1333
- if (nm._backupLatlng) {
1334
- nm.setLatLng(nm._backupLatlng);
1335
- delete nm._backupLatlng;
1336
- }
1337
- }
1338
- if (zoomLevel - 1 === this._zoom) {
1339
- for (let j = this._childClusters.length - 1; j >= 0; j--) {
1340
- this._childClusters[j]._restorePosition();
1341
- }
1342
- } else {
1343
- for (let k = this._childClusters.length - 1; k >= 0; k--) {
1344
- this._childClusters[k]._recursivelyRestoreChildPositions(zoomLevel);
1345
- }
773
+ _recursivelyRestoreChildPositions: function(t) {
774
+ for (let e = this._markers.length - 1; e >= 0; e--) {
775
+ const i = this._markers[e];
776
+ i._backupLatlng && (i.setLatLng(i._backupLatlng), delete i._backupLatlng);
1346
777
  }
778
+ if (t - 1 === this._zoom)
779
+ for (let e = this._childClusters.length - 1; e >= 0; e--)
780
+ this._childClusters[e]._restorePosition();
781
+ else
782
+ for (let e = this._childClusters.length - 1; e >= 0; e--)
783
+ this._childClusters[e]._recursivelyRestoreChildPositions(t);
1347
784
  },
1348
785
  _restorePosition: function() {
1349
- if (this._backupLatlng) {
1350
- this.setLatLng(this._backupLatlng);
1351
- delete this._backupLatlng;
1352
- }
786
+ this._backupLatlng && (this.setLatLng(this._backupLatlng), delete this._backupLatlng);
1353
787
  },
1354
788
  //exceptBounds: If set, don't remove any markers/clusters in it
1355
- _recursivelyRemoveChildrenFromMap: function(previousBounds, mapMinZoom, zoomLevel, exceptBounds) {
1356
- var m, i;
789
+ _recursivelyRemoveChildrenFromMap: function(t, e, i, n) {
790
+ var s, o;
1357
791
  this._recursively(
1358
- previousBounds,
1359
- mapMinZoom - 1,
1360
- zoomLevel - 1,
1361
- (c) => {
1362
- for (i = c._markers.length - 1; i >= 0; i--) {
1363
- m = c._markers[i];
1364
- if (!exceptBounds || !exceptBounds.contains(m._latlng)) {
1365
- c._group._featureGroup.removeLayer(m);
1366
- if (m.clusterShow) {
1367
- m.clusterShow();
1368
- }
1369
- }
1370
- }
792
+ t,
793
+ e - 1,
794
+ i - 1,
795
+ (r) => {
796
+ for (o = r._markers.length - 1; o >= 0; o--)
797
+ s = r._markers[o], (!n || !n.contains(s._latlng)) && (r._group._featureGroup.removeLayer(s), s.clusterShow && s.clusterShow());
1371
798
  },
1372
- (c) => {
1373
- for (i = c._childClusters.length - 1; i >= 0; i--) {
1374
- m = c._childClusters[i];
1375
- if (!exceptBounds || !exceptBounds.contains(m._latlng)) {
1376
- c._group._featureGroup.removeLayer(m);
1377
- if (m.clusterShow) {
1378
- m.clusterShow();
1379
- }
1380
- }
1381
- }
799
+ (r) => {
800
+ for (o = r._childClusters.length - 1; o >= 0; o--)
801
+ s = r._childClusters[o], (!n || !n.contains(s._latlng)) && (r._group._featureGroup.removeLayer(s), s.clusterShow && s.clusterShow());
1382
802
  }
1383
803
  );
1384
804
  },
@@ -1388,250 +808,162 @@ L.MarkerCluster = L.Marker.extend({
1388
808
  // zoomLevelToStop: zoom level to stop running functions (inclusive)
1389
809
  // runAtEveryLevel: function that takes an L.MarkerCluster as an argument that should be applied on every level
1390
810
  // runAtBottomLevel: function that takes an L.MarkerCluster as an argument that should be applied at only the bottom level
1391
- _recursively: function(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel) {
1392
- var childClusters = this._childClusters, zoom = this._zoom, i, c;
1393
- if (zoomLevelToStart <= zoom) {
1394
- if (runAtEveryLevel) {
1395
- runAtEveryLevel(this);
1396
- }
1397
- if (runAtBottomLevel && zoom === zoomLevelToStop) {
1398
- runAtBottomLevel(this);
1399
- }
1400
- }
1401
- if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) {
1402
- for (i = childClusters.length - 1; i >= 0; i--) {
1403
- c = childClusters[i];
1404
- if (boundsToApplyTo.intersects(c._bounds)) {
1405
- c._recursively(
1406
- boundsToApplyTo,
1407
- zoomLevelToStart,
1408
- zoomLevelToStop,
1409
- runAtEveryLevel,
1410
- runAtBottomLevel
1411
- );
1412
- }
1413
- }
1414
- }
811
+ _recursively: function(t, e, i, n, s) {
812
+ var o = this._childClusters, r = this._zoom, a, h;
813
+ if (e <= r && (n && n(this), s && r === i && s(this)), r < e || r < i)
814
+ for (a = o.length - 1; a >= 0; a--)
815
+ h = o[a], t.intersects(h._bounds) && h._recursively(
816
+ t,
817
+ e,
818
+ i,
819
+ n,
820
+ s
821
+ );
1415
822
  },
1416
823
  //Returns true if we are the parent of only one cluster and that cluster is the same as us
1417
824
  _isSingleParent: function() {
1418
825
  return this._childClusters.length > 0 && this._childClusters[0]._childCount === this._childCount;
1419
826
  }
1420
827
  });
1421
- L.Marker.include({
828
+ u.Marker.include({
1422
829
  clusterHide: function() {
1423
- this.options.opacityWhenUnclustered = this.options.opacity || 1;
1424
- return this.setOpacity(0);
830
+ return this.options.opacityWhenUnclustered = this.options.opacity || 1, this.setOpacity(0);
1425
831
  },
1426
832
  clusterShow: function() {
1427
- var ret = this.setOpacity(
833
+ var t = this.setOpacity(
1428
834
  this.options.opacity || this.options.opacityWhenUnclustered
1429
835
  );
1430
- delete this.options.opacityWhenUnclustered;
1431
- return ret;
836
+ return delete this.options.opacityWhenUnclustered, t;
1432
837
  }
1433
838
  });
1434
- L.DistanceGrid = function(cellSize) {
1435
- this._cellSize = cellSize;
1436
- this._sqCellSize = cellSize * cellSize;
1437
- this._grid = {};
1438
- this._objectPoint = {};
839
+ u.DistanceGrid = function(t) {
840
+ this._cellSize = t, this._sqCellSize = t * t, this._grid = {}, this._objectPoint = {};
1439
841
  };
1440
- L.DistanceGrid.prototype = {
1441
- addObject: function(obj, point) {
1442
- var x = this._getCoord(point.x);
1443
- var y = this._getCoord(point.y);
1444
- var grid = this._grid;
1445
- grid[y] = grid[y] || {};
1446
- var row = grid[y];
1447
- row[x] = row[x] || [];
1448
- var cell = row[x];
1449
- var stamp = L.Util.stamp(obj);
1450
- this._objectPoint[stamp] = point;
1451
- cell.push(obj);
1452
- },
1453
- updateObject: function(obj, point) {
1454
- this.removeObject(obj);
1455
- this.addObject(obj, point);
842
+ u.DistanceGrid.prototype = {
843
+ addObject: function(t, e) {
844
+ var i = this._getCoord(e.x), n = this._getCoord(e.y), s = this._grid;
845
+ s[n] = s[n] || {};
846
+ var o = s[n];
847
+ o[i] = o[i] || [];
848
+ var r = o[i], a = u.Util.stamp(t);
849
+ this._objectPoint[a] = e, r.push(t);
850
+ },
851
+ updateObject: function(t, e) {
852
+ this.removeObject(t), this.addObject(t, e);
1456
853
  },
1457
854
  //Returns true if the object was found
1458
- removeObject: function(obj, point) {
1459
- var x = this._getCoord(point.x);
1460
- var y = this._getCoord(point.y);
1461
- var grid = this._grid;
1462
- grid[y] = grid[y] || {};
1463
- var row = grid[y];
1464
- row[x] = row[x] || [];
1465
- var cell = row[x];
1466
- var i, len;
1467
- delete this._objectPoint[L.Util.stamp(obj)];
1468
- for (i = 0, len = cell.length; i < len; i++) {
1469
- if (cell[i] === obj) {
1470
- cell.splice(i, 1);
1471
- if (len === 1) {
1472
- delete row[x];
1473
- }
1474
- return true;
1475
- }
1476
- }
1477
- },
1478
- eachObject: function(fn, context) {
1479
- var i, j, k, len, row, cell, removed, grid = this._grid;
1480
- for (i in grid) {
1481
- row = grid[i];
1482
- for (j in row) {
1483
- cell = row[j];
1484
- for (k = 0, len = cell.length; k < len; k++) {
1485
- removed = fn.call(context, cell[k]);
1486
- if (removed) {
1487
- k--;
1488
- len--;
1489
- }
1490
- }
1491
- }
1492
- }
1493
- },
1494
- getNearObject: function(point) {
1495
- var x = this._getCoord(point.x), y = this._getCoord(point.y), i, j, k, row, cell, len, obj, dist, objectPoint = this._objectPoint, closestDistSq = this._sqCellSize, closest = null;
1496
- for (i = y - 1; i <= y + 1; i++) {
1497
- row = this._grid[i];
1498
- if (row) {
1499
- for (j = x - 1; j <= x + 1; j++) {
1500
- cell = row[j];
1501
- if (cell) {
1502
- for (k = 0, len = cell.length; k < len; k++) {
1503
- obj = cell[k];
1504
- dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point);
1505
- if (dist < closestDistSq) {
1506
- closestDistSq = dist;
1507
- closest = obj;
1508
- }
1509
- }
1510
- }
1511
- }
1512
- }
855
+ removeObject: function(t, e) {
856
+ var i = this._getCoord(e.x), n = this._getCoord(e.y), s = this._grid;
857
+ s[n] = s[n] || {};
858
+ var o = s[n];
859
+ o[i] = o[i] || [];
860
+ var r = o[i], a, h;
861
+ for (delete this._objectPoint[u.Util.stamp(t)], a = 0, h = r.length; a < h; a++)
862
+ if (r[a] === t)
863
+ return r.splice(a, 1), h === 1 && delete o[i], !0;
864
+ },
865
+ eachObject: function(t, e) {
866
+ var i, n, s, o, r, a, h, _ = this._grid;
867
+ for (i in _) {
868
+ r = _[i];
869
+ for (n in r)
870
+ for (a = r[n], s = 0, o = a.length; s < o; s++)
871
+ h = t.call(e, a[s]), h && (s--, o--);
872
+ }
873
+ },
874
+ getNearObject: function(t) {
875
+ var e = this._getCoord(t.x), i = this._getCoord(t.y), n, s, o, r, a, h, _, l, d = this._objectPoint, p = this._sqCellSize, f = null;
876
+ for (n = i - 1; n <= i + 1; n++)
877
+ if (r = this._grid[n], r) {
878
+ for (s = e - 1; s <= e + 1; s++)
879
+ if (a = r[s], a)
880
+ for (o = 0, h = a.length; o < h; o++)
881
+ _ = a[o], l = this._sqDist(d[u.Util.stamp(_)], t), l < p && (p = l, f = _);
882
+ }
883
+ return f;
884
+ },
885
+ _getCoord: function(t) {
886
+ return Math.floor(t / this._cellSize);
887
+ },
888
+ _sqDist: (t, e) => {
889
+ var i = e.x - t.x, n = e.y - t.y;
890
+ return i * i + n * n;
891
+ }
892
+ };
893
+ u.QuickHull = {
894
+ /*
895
+ * @param {Object} cpt a point to be measured from the baseline
896
+ * @param {Array} bl the baseline, as represented by a two-element
897
+ * array of latlng objects.
898
+ * @returns {Number} an approximate distance measure
899
+ */
900
+ getDistant: (t, e) => {
901
+ var i = e[1].lat - e[0].lat, n = e[0].lng - e[1].lng;
902
+ return n * (t.lat - e[0].lat) + i * (t.lng - e[0].lng);
903
+ },
904
+ /*
905
+ * @param {Array} baseLine a two-element array of latlng objects
906
+ * representing the baseline to project from
907
+ * @param {Array} latLngs an array of latlng objects
908
+ * @returns {Object} the maximum point and all new points to stay
909
+ * in consideration for the hull.
910
+ */
911
+ findMostDistantPointFromBaseLine: function(t, e) {
912
+ var i = 0, n = null, s = [], o, r, a;
913
+ for (o = e.length - 1; o >= 0; o--) {
914
+ if (r = e[o], a = this.getDistant(r, t), a > 0)
915
+ s.push(r);
916
+ else
917
+ continue;
918
+ a > i && (i = a, n = r);
1513
919
  }
1514
- return closest;
1515
- },
1516
- _getCoord: function(x) {
1517
- return Math.floor(x / this._cellSize);
920
+ return { maxPoint: n, newPoints: s };
1518
921
  },
1519
- _sqDist: (p, p2) => {
1520
- var dx = p2.x - p.x, dy = p2.y - p.y;
1521
- return dx * dx + dy * dy;
922
+ /*
923
+ * Given a baseline, compute the convex hull of latLngs as an array
924
+ * of latLngs.
925
+ *
926
+ * @param {Array} latLngs
927
+ * @returns {Array}
928
+ */
929
+ buildConvexHull: function(t, e) {
930
+ var i = [], n = this.findMostDistantPointFromBaseLine(t, e);
931
+ return n.maxPoint ? (i = i.concat(
932
+ this.buildConvexHull([t[0], n.maxPoint], n.newPoints)
933
+ ), i = i.concat(
934
+ this.buildConvexHull([n.maxPoint, t[1]], n.newPoints)
935
+ ), i) : [t[0]];
936
+ },
937
+ /*
938
+ * Given an array of latlngs, compute a convex hull as an array
939
+ * of latlngs
940
+ *
941
+ * @param {Array} latLngs
942
+ * @returns {Array}
943
+ */
944
+ getConvexHull: function(t) {
945
+ var e = !1, i = !1, n = !1, s = !1, o = null, r = null, a = null, h = null, _ = null, l = null, d;
946
+ for (d = t.length - 1; d >= 0; d--) {
947
+ const f = t[d];
948
+ (e === !1 || f.lat > e) && (o = f, e = f.lat), (i === !1 || f.lat < i) && (r = f, i = f.lat), (n === !1 || f.lng > n) && (a = f, n = f.lng), (s === !1 || f.lng < s) && (h = f, s = f.lng);
949
+ }
950
+ i !== e ? (l = r, _ = o) : (l = h, _ = a);
951
+ var p = [].concat(
952
+ this.buildConvexHull([l, _], t),
953
+ this.buildConvexHull([_, l], t)
954
+ );
955
+ return p;
1522
956
  }
1523
957
  };
1524
- (() => {
1525
- L.QuickHull = {
1526
- /*
1527
- * @param {Object} cpt a point to be measured from the baseline
1528
- * @param {Array} bl the baseline, as represented by a two-element
1529
- * array of latlng objects.
1530
- * @returns {Number} an approximate distance measure
1531
- */
1532
- getDistant: (cpt, bl) => {
1533
- var vY = bl[1].lat - bl[0].lat, vX = bl[0].lng - bl[1].lng;
1534
- return vX * (cpt.lat - bl[0].lat) + vY * (cpt.lng - bl[0].lng);
1535
- },
1536
- /*
1537
- * @param {Array} baseLine a two-element array of latlng objects
1538
- * representing the baseline to project from
1539
- * @param {Array} latLngs an array of latlng objects
1540
- * @returns {Object} the maximum point and all new points to stay
1541
- * in consideration for the hull.
1542
- */
1543
- findMostDistantPointFromBaseLine: function(baseLine, latLngs) {
1544
- var maxD = 0, maxPt = null, newPoints = [], i, pt, d;
1545
- for (i = latLngs.length - 1; i >= 0; i--) {
1546
- pt = latLngs[i];
1547
- d = this.getDistant(pt, baseLine);
1548
- if (d > 0) {
1549
- newPoints.push(pt);
1550
- } else {
1551
- continue;
1552
- }
1553
- if (d > maxD) {
1554
- maxD = d;
1555
- maxPt = pt;
1556
- }
1557
- }
1558
- return { maxPoint: maxPt, newPoints };
1559
- },
1560
- /*
1561
- * Given a baseline, compute the convex hull of latLngs as an array
1562
- * of latLngs.
1563
- *
1564
- * @param {Array} latLngs
1565
- * @returns {Array}
1566
- */
1567
- buildConvexHull: function(baseLine, latLngs) {
1568
- var convexHullBaseLines = [], t = this.findMostDistantPointFromBaseLine(baseLine, latLngs);
1569
- if (t.maxPoint) {
1570
- convexHullBaseLines = convexHullBaseLines.concat(
1571
- this.buildConvexHull([baseLine[0], t.maxPoint], t.newPoints)
1572
- );
1573
- convexHullBaseLines = convexHullBaseLines.concat(
1574
- this.buildConvexHull([t.maxPoint, baseLine[1]], t.newPoints)
1575
- );
1576
- return convexHullBaseLines;
1577
- } else {
1578
- return [baseLine[0]];
1579
- }
1580
- },
1581
- /*
1582
- * Given an array of latlngs, compute a convex hull as an array
1583
- * of latlngs
1584
- *
1585
- * @param {Array} latLngs
1586
- * @returns {Array}
1587
- */
1588
- getConvexHull: function(latLngs) {
1589
- var maxLat = false, minLat = false, maxLng = false, minLng = false, maxLatPt = null, minLatPt = null, maxLngPt = null, minLngPt = null, maxPt = null, minPt = null, i;
1590
- for (i = latLngs.length - 1; i >= 0; i--) {
1591
- const pt = latLngs[i];
1592
- if (maxLat === false || pt.lat > maxLat) {
1593
- maxLatPt = pt;
1594
- maxLat = pt.lat;
1595
- }
1596
- if (minLat === false || pt.lat < minLat) {
1597
- minLatPt = pt;
1598
- minLat = pt.lat;
1599
- }
1600
- if (maxLng === false || pt.lng > maxLng) {
1601
- maxLngPt = pt;
1602
- maxLng = pt.lng;
1603
- }
1604
- if (minLng === false || pt.lng < minLng) {
1605
- minLngPt = pt;
1606
- minLng = pt.lng;
1607
- }
1608
- }
1609
- if (minLat !== maxLat) {
1610
- minPt = minLatPt;
1611
- maxPt = maxLatPt;
1612
- } else {
1613
- minPt = minLngPt;
1614
- maxPt = maxLngPt;
1615
- }
1616
- var ch = [].concat(
1617
- this.buildConvexHull([minPt, maxPt], latLngs),
1618
- this.buildConvexHull([maxPt, minPt], latLngs)
1619
- );
1620
- return ch;
1621
- }
1622
- };
1623
- })();
1624
- L.MarkerCluster.include({
958
+ u.MarkerCluster.include({
1625
959
  getConvexHull: function() {
1626
- var childMarkers = this.getAllChildMarkers(), points = [], p, i;
1627
- for (i = childMarkers.length - 1; i >= 0; i--) {
1628
- p = childMarkers[i].getLatLng();
1629
- points.push(p);
1630
- }
1631
- return L.QuickHull.getConvexHull(points);
960
+ var t = this.getAllChildMarkers(), e = [], i, n;
961
+ for (n = t.length - 1; n >= 0; n--)
962
+ i = t[n].getLatLng(), e.push(i);
963
+ return u.QuickHull.getConvexHull(e);
1632
964
  }
1633
965
  });
1634
- L.MarkerCluster.include({
966
+ u.MarkerCluster.include({
1635
967
  _2PI: Math.PI * 2,
1636
968
  _circleFootSeparation: 25,
1637
969
  //related to circumference of circle
@@ -1644,311 +976,129 @@ L.MarkerCluster.include({
1644
976
  //show spiral instead of circle from this marker count upwards.
1645
977
  // 0 -> always spiral; Infinity -> always circle
1646
978
  spiderfy: function() {
1647
- if (this._group._spiderfied === this || this._group._inZoomAnimation) {
1648
- return;
1649
- }
1650
- var childMarkers = this.getAllChildMarkers(), group = this._group, map = group._map, center = map.latLngToLayerPoint(this._latlng), positions;
1651
- this._group._unspiderfy();
1652
- this._group._spiderfied = this;
1653
- if (childMarkers.length >= this._circleSpiralSwitchover) {
1654
- positions = this._generatePointsSpiral(childMarkers.length, center);
1655
- } else {
1656
- center.y += 10;
1657
- positions = this._generatePointsCircle(childMarkers.length, center);
979
+ if (!(this._group._spiderfied === this || this._group._inZoomAnimation)) {
980
+ var t = this.getAllChildMarkers(), e = this._group, i = e._map, n = i.latLngToLayerPoint(this._latlng), s;
981
+ this._group._unspiderfy(), this._group._spiderfied = this, t.length >= this._circleSpiralSwitchover ? s = this._generatePointsSpiral(t.length, n) : (n.y += 10, s = this._generatePointsCircle(t.length, n)), this._animationSpiderfy(t, s);
1658
982
  }
1659
- this._animationSpiderfy(childMarkers, positions);
1660
983
  },
1661
- unspiderfy: function(zoomDetails) {
1662
- if (this._group._inZoomAnimation) {
1663
- return;
1664
- }
1665
- this._animationUnspiderfy(zoomDetails);
1666
- this._group._spiderfied = null;
1667
- },
1668
- _generatePointsCircle: function(count, centerPt) {
1669
- var circumference = this._group.options.spiderfyDistanceMultiplier * this._circleFootSeparation * (2 + count), legLength = circumference / this._2PI, angleStep = this._2PI / count, res = [], i, angle;
1670
- res.length = count;
1671
- for (i = count - 1; i >= 0; i--) {
1672
- angle = this._circleStartAngle + i * angleStep;
1673
- res[i] = new L.Point(
1674
- centerPt.x + legLength * Math.cos(angle),
1675
- centerPt.y + legLength * Math.sin(angle)
1676
- )._round();
1677
- }
1678
- return res;
1679
- },
1680
- _generatePointsSpiral: function(count, centerPt) {
1681
- var spiderfyDistanceMultiplier = this._group.options.spiderfyDistanceMultiplier, legLength = spiderfyDistanceMultiplier * this._spiralLengthStart, separation = spiderfyDistanceMultiplier * this._spiralFootSeparation, lengthFactor = spiderfyDistanceMultiplier * this._spiralLengthFactor * this._2PI, angle = 0, res = [], i;
1682
- res.length = count;
1683
- for (i = count - 1; i >= 0; i--) {
1684
- angle += separation / legLength + i * 5e-4;
1685
- res[i] = new L.Point(
1686
- centerPt.x + legLength * Math.cos(angle),
1687
- centerPt.y + legLength * Math.sin(angle)
984
+ unspiderfy: function(t) {
985
+ this._group._inZoomAnimation || (this._animationUnspiderfy(t), this._group._spiderfied = null);
986
+ },
987
+ _generatePointsCircle: function(t, e) {
988
+ var i = this._group.options.spiderfyDistanceMultiplier * this._circleFootSeparation * (2 + t), n = i / this._2PI, s = this._2PI / t, o = [], r, a;
989
+ for (o.length = t, r = t - 1; r >= 0; r--)
990
+ a = this._circleStartAngle + r * s, o[r] = new u.Point(
991
+ e.x + n * Math.cos(a),
992
+ e.y + n * Math.sin(a)
1688
993
  )._round();
1689
- legLength += lengthFactor / angle;
1690
- }
1691
- return res;
994
+ return o;
995
+ },
996
+ _generatePointsSpiral: function(t, e) {
997
+ var i = this._group.options.spiderfyDistanceMultiplier, n = i * this._spiralLengthStart, s = i * this._spiralFootSeparation, o = i * this._spiralLengthFactor * this._2PI, r = 0, a = [], h;
998
+ for (a.length = t, h = t - 1; h >= 0; h--)
999
+ r += s / n + h * 5e-4, a[h] = new u.Point(
1000
+ e.x + n * Math.cos(r),
1001
+ e.y + n * Math.sin(r)
1002
+ )._round(), n += o / r;
1003
+ return a;
1692
1004
  },
1693
1005
  _noanimationUnspiderfy: function() {
1694
- var group = this._group, map = group._map, fg = group._featureGroup, childMarkers = this.getAllChildMarkers(), m, i;
1695
- group._ignoreMove = true;
1696
- this.setOpacity(1);
1697
- for (i = childMarkers.length - 1; i >= 0; i--) {
1698
- m = childMarkers[i];
1699
- fg.removeLayer(m);
1700
- if (m._preSpiderfyLatlng) {
1701
- m.setLatLng(m._preSpiderfyLatlng);
1702
- delete m._preSpiderfyLatlng;
1703
- }
1704
- if (m.setZIndexOffset) {
1705
- m.setZIndexOffset(0);
1706
- }
1707
- if (m._spiderLeg) {
1708
- map.removeLayer(m._spiderLeg);
1709
- delete m._spiderLeg;
1710
- }
1711
- }
1712
- group.fire("unspiderfied", {
1006
+ var t = this._group, e = t._map, i = t._featureGroup, n = this.getAllChildMarkers(), s, o;
1007
+ for (t._ignoreMove = !0, this.setOpacity(1), o = n.length - 1; o >= 0; o--)
1008
+ s = n[o], i.removeLayer(s), s._preSpiderfyLatlng && (s.setLatLng(s._preSpiderfyLatlng), delete s._preSpiderfyLatlng), s.setZIndexOffset && s.setZIndexOffset(0), s._spiderLeg && (e.removeLayer(s._spiderLeg), delete s._spiderLeg);
1009
+ t.fire("unspiderfied", {
1713
1010
  cluster: this,
1714
- markers: childMarkers
1715
- });
1716
- group._ignoreMove = false;
1717
- group._spiderfied = null;
1011
+ markers: n
1012
+ }), t._ignoreMove = !1, t._spiderfied = null;
1718
1013
  }
1719
1014
  });
1720
- L.MarkerClusterNonAnimated = L.MarkerCluster.extend({
1721
- _animationSpiderfy: function(childMarkers, positions) {
1722
- var group = this._group, map = group._map, fg = group._featureGroup, legOptions = this._group.options.spiderLegPolylineOptions, i, m, leg, newPos;
1723
- group._ignoreMove = true;
1724
- for (i = 0; i < childMarkers.length; i++) {
1725
- newPos = map.layerPointToLatLng(positions[i]);
1726
- m = childMarkers[i];
1727
- leg = new L.Polyline([this._latlng, newPos], legOptions);
1728
- map.addLayer(leg);
1729
- m._spiderLeg = leg;
1730
- m._preSpiderfyLatlng = m._latlng;
1731
- m.setLatLng(newPos);
1732
- if (m.setZIndexOffset) {
1733
- m.setZIndexOffset(1e6);
1734
- }
1735
- fg.addLayer(m);
1736
- }
1737
- this.setOpacity(0.3);
1738
- group._ignoreMove = false;
1739
- group.fire("spiderfied", {
1015
+ u.MarkerClusterNonAnimated = u.MarkerCluster.extend({
1016
+ _animationSpiderfy: function(t, e) {
1017
+ var i = this._group, n = i._map, s = i._featureGroup, o = this._group.options.spiderLegPolylineOptions, r, a, h, _;
1018
+ for (i._ignoreMove = !0, r = 0; r < t.length; r++)
1019
+ _ = n.layerPointToLatLng(e[r]), a = t[r], h = new u.Polyline([this._latlng, _], o), n.addLayer(h), a._spiderLeg = h, a._preSpiderfyLatlng = a._latlng, a.setLatLng(_), a.setZIndexOffset && a.setZIndexOffset(1e6), s.addLayer(a);
1020
+ this.setOpacity(0.3), i._ignoreMove = !1, i.fire("spiderfied", {
1740
1021
  cluster: this,
1741
- markers: childMarkers
1022
+ markers: t
1742
1023
  });
1743
1024
  },
1744
1025
  _animationUnspiderfy: function() {
1745
1026
  this._noanimationUnspiderfy();
1746
1027
  }
1747
1028
  });
1748
- L.MarkerCluster.include({
1749
- _animationSpiderfy: function(childMarkers, positions) {
1750
- var group = this._group, map = group._map, fg = group._featureGroup, thisLayerLatLng = this._latlng, thisLayerPos = map.latLngToLayerPoint(thisLayerLatLng), svg = L.Path.SVG, legOptions = Object.assign(
1029
+ u.MarkerCluster.include({
1030
+ _animationSpiderfy: function(t, e) {
1031
+ var i = this._group, n = i._map, s = i._featureGroup, o = this._latlng, r = n.latLngToLayerPoint(o), a = u.Path.SVG, h = Object.assign(
1751
1032
  {},
1752
1033
  this._group.options.spiderLegPolylineOptions
1753
- ), finalLegOpacity = legOptions.opacity, i, m, leg, legPath, legLength, newPos;
1754
- if (finalLegOpacity === void 0) {
1755
- finalLegOpacity = L.MarkerClusterGroup.prototype.options.spiderLegPolylineOptions.opacity;
1756
- }
1757
- if (svg) {
1758
- legOptions.opacity = 0;
1759
- legOptions.className = `${legOptions.className || ""} leaflet-cluster-spider-leg`;
1760
- } else {
1761
- legOptions.opacity = finalLegOpacity;
1762
- }
1763
- group._ignoreMove = true;
1764
- for (i = 0; i < childMarkers.length; i++) {
1765
- m = childMarkers[i];
1766
- newPos = map.layerPointToLatLng(positions[i]);
1767
- leg = new L.Polyline([thisLayerLatLng, newPos], legOptions);
1768
- map.addLayer(leg);
1769
- m._spiderLeg = leg;
1770
- if (svg) {
1771
- legPath = leg._path;
1772
- legLength = legPath.getTotalLength() + 0.1;
1773
- legPath.style.strokeDasharray = legLength;
1774
- legPath.style.strokeDashoffset = legLength;
1775
- }
1776
- if (m.setZIndexOffset) {
1777
- m.setZIndexOffset(1e6);
1778
- }
1779
- if (m.clusterHide) {
1780
- m.clusterHide();
1781
- }
1782
- fg.addLayer(m);
1783
- if (m._setPos) {
1784
- m._setPos(thisLayerPos);
1785
- }
1786
- }
1787
- group._forceLayout();
1788
- group._animationStart();
1789
- for (i = childMarkers.length - 1; i >= 0; i--) {
1790
- newPos = map.layerPointToLatLng(positions[i]);
1791
- m = childMarkers[i];
1792
- m._preSpiderfyLatlng = m._latlng;
1793
- m.setLatLng(newPos);
1794
- if (m.clusterShow) {
1795
- m.clusterShow();
1796
- }
1797
- if (svg) {
1798
- leg = m._spiderLeg;
1799
- legPath = leg._path;
1800
- legPath.style.strokeDashoffset = 0;
1801
- leg.setStyle({ opacity: finalLegOpacity });
1802
- }
1803
- }
1804
- this.setOpacity(0.3);
1805
- group._ignoreMove = false;
1806
- setTimeout(() => {
1807
- group._animationEnd();
1808
- group.fire("spiderfied", {
1034
+ ), _ = h.opacity, l, d, p, f, c, g;
1035
+ for (_ === void 0 && (_ = u.MarkerClusterGroup.prototype.options.spiderLegPolylineOptions.opacity), a ? (h.opacity = 0, h.className = `${h.className || ""} leaflet-cluster-spider-leg`) : h.opacity = _, i._ignoreMove = !0, l = 0; l < t.length; l++)
1036
+ d = t[l], g = n.layerPointToLatLng(e[l]), p = new u.Polyline([o, g], h), n.addLayer(p), d._spiderLeg = p, a && (f = p._path, c = f.getTotalLength() + 0.1, f.style.strokeDasharray = c, f.style.strokeDashoffset = c), d.setZIndexOffset && d.setZIndexOffset(1e6), d.clusterHide && d.clusterHide(), s.addLayer(d), d._setPos && d._setPos(r);
1037
+ for (i._forceLayout(), i._animationStart(), l = t.length - 1; l >= 0; l--)
1038
+ g = n.layerPointToLatLng(e[l]), d = t[l], d._preSpiderfyLatlng = d._latlng, d.setLatLng(g), d.clusterShow && d.clusterShow(), a && (p = d._spiderLeg, f = p._path, f.style.strokeDashoffset = 0, p.setStyle({ opacity: _ }));
1039
+ this.setOpacity(0.3), i._ignoreMove = !1, setTimeout(() => {
1040
+ i._animationEnd(), i.fire("spiderfied", {
1809
1041
  cluster: this,
1810
- markers: childMarkers
1042
+ markers: t
1811
1043
  });
1812
1044
  }, 200);
1813
1045
  },
1814
- _animationUnspiderfy: function(zoomDetails) {
1815
- var group = this._group, map = group._map, fg = group._featureGroup, thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(
1046
+ _animationUnspiderfy: function(t) {
1047
+ var e = this._group, i = e._map, n = e._featureGroup, s = t ? i._latLngToNewLayerPoint(
1816
1048
  this._latlng,
1817
- zoomDetails.zoom,
1818
- zoomDetails.center
1819
- ) : map.latLngToLayerPoint(this._latlng), childMarkers = this.getAllChildMarkers(), svg = L.Path.SVG, m, i, leg, legPath, legLength, nonAnimatable;
1820
- group._ignoreMove = true;
1821
- group._animationStart();
1822
- this.setOpacity(1);
1823
- for (i = childMarkers.length - 1; i >= 0; i--) {
1824
- m = childMarkers[i];
1825
- if (!m._preSpiderfyLatlng) {
1826
- continue;
1827
- }
1828
- m.closePopup();
1829
- m.setLatLng(m._preSpiderfyLatlng);
1830
- delete m._preSpiderfyLatlng;
1831
- nonAnimatable = true;
1832
- if (m._setPos) {
1833
- m._setPos(thisLayerPos);
1834
- nonAnimatable = false;
1835
- }
1836
- if (m.clusterHide) {
1837
- m.clusterHide();
1838
- nonAnimatable = false;
1839
- }
1840
- if (nonAnimatable) {
1841
- fg.removeLayer(m);
1842
- }
1843
- if (svg) {
1844
- leg = m._spiderLeg;
1845
- legPath = leg._path;
1846
- legLength = legPath.getTotalLength() + 0.1;
1847
- legPath.style.strokeDashoffset = legLength;
1848
- leg.setStyle({ opacity: 0 });
1849
- }
1850
- }
1851
- group._ignoreMove = false;
1852
- setTimeout(() => {
1853
- var stillThereChildCount = 0;
1854
- for (i = childMarkers.length - 1; i >= 0; i--) {
1855
- m = childMarkers[i];
1856
- if (m._spiderLeg) {
1857
- stillThereChildCount++;
1858
- }
1859
- }
1860
- for (i = childMarkers.length - 1; i >= 0; i--) {
1861
- m = childMarkers[i];
1862
- if (!m._spiderLeg) {
1863
- continue;
1864
- }
1865
- if (m.clusterShow) {
1866
- m.clusterShow();
1867
- }
1868
- if (m.setZIndexOffset) {
1869
- m.setZIndexOffset(0);
1870
- }
1871
- if (stillThereChildCount > 1) {
1872
- fg.removeLayer(m);
1873
- }
1874
- map.removeLayer(m._spiderLeg);
1875
- delete m._spiderLeg;
1876
- }
1877
- group._animationEnd();
1878
- group.fire("unspiderfied", {
1049
+ t.zoom,
1050
+ t.center
1051
+ ) : i.latLngToLayerPoint(this._latlng), o = this.getAllChildMarkers(), r = u.Path.SVG, a, h, _, l, d, p;
1052
+ for (e._ignoreMove = !0, e._animationStart(), this.setOpacity(1), h = o.length - 1; h >= 0; h--)
1053
+ a = o[h], a._preSpiderfyLatlng && (a.closePopup(), a.setLatLng(a._preSpiderfyLatlng), delete a._preSpiderfyLatlng, p = !0, a._setPos && (a._setPos(s), p = !1), a.clusterHide && (a.clusterHide(), p = !1), p && n.removeLayer(a), r && (_ = a._spiderLeg, l = _._path, d = l.getTotalLength() + 0.1, l.style.strokeDashoffset = d, _.setStyle({ opacity: 0 })));
1054
+ e._ignoreMove = !1, setTimeout(() => {
1055
+ var f = 0;
1056
+ for (h = o.length - 1; h >= 0; h--)
1057
+ a = o[h], a._spiderLeg && f++;
1058
+ for (h = o.length - 1; h >= 0; h--)
1059
+ a = o[h], a._spiderLeg && (a.clusterShow && a.clusterShow(), a.setZIndexOffset && a.setZIndexOffset(0), f > 1 && n.removeLayer(a), i.removeLayer(a._spiderLeg), delete a._spiderLeg);
1060
+ e._animationEnd(), e.fire("unspiderfied", {
1879
1061
  cluster: this,
1880
- markers: childMarkers
1062
+ markers: o
1881
1063
  });
1882
1064
  }, 200);
1883
1065
  }
1884
1066
  });
1885
- L.MarkerClusterGroup.include({
1067
+ u.MarkerClusterGroup.include({
1886
1068
  //The MarkerCluster currently spiderfied (if any)
1887
1069
  _spiderfied: null,
1888
- unspiderfy: function(...args) {
1889
- this._unspiderfy.apply(this, args);
1070
+ unspiderfy: function(...t) {
1071
+ this._unspiderfy.apply(this, t);
1890
1072
  },
1891
1073
  _spiderfierOnAdd: function() {
1892
- this._map.on("click", this._unspiderfyWrapper, this);
1893
- if (this._map.options.zoomAnimation) {
1894
- this._map.on("zoomstart", this._unspiderfyZoomStart, this);
1895
- }
1896
- this._map.on("zoomend", this._noanimationUnspiderfy, this);
1897
- if (!L.Browser.touch) {
1898
- this._map.getRenderer(this);
1899
- }
1074
+ this._map.on("click", this._unspiderfyWrapper, this), this._map.options.zoomAnimation && this._map.on("zoomstart", this._unspiderfyZoomStart, this), this._map.on("zoomend", this._noanimationUnspiderfy, this), u.Browser.touch || this._map.getRenderer(this);
1900
1075
  },
1901
1076
  _spiderfierOnRemove: function() {
1902
- this._map.off("click", this._unspiderfyWrapper, this);
1903
- this._map.off("zoomstart", this._unspiderfyZoomStart, this);
1904
- this._map.off("zoomanim", this._unspiderfyZoomAnim, this);
1905
- this._map.off("zoomend", this._noanimationUnspiderfy, this);
1906
- this._noanimationUnspiderfy();
1077
+ this._map.off("click", this._unspiderfyWrapper, this), this._map.off("zoomstart", this._unspiderfyZoomStart, this), this._map.off("zoomanim", this._unspiderfyZoomAnim, this), this._map.off("zoomend", this._noanimationUnspiderfy, this), this._noanimationUnspiderfy();
1907
1078
  },
1908
1079
  //On zoom start we add a zoomanim handler so that we are guaranteed to be last (after markers are animated)
1909
1080
  //This means we can define the animation they do rather than Markers doing an animation to their actual location
1910
1081
  _unspiderfyZoomStart: function() {
1911
- if (!this._map) {
1912
- return;
1913
- }
1914
- this._map.on("zoomanim", this._unspiderfyZoomAnim, this);
1082
+ this._map && this._map.on("zoomanim", this._unspiderfyZoomAnim, this);
1915
1083
  },
1916
- _unspiderfyZoomAnim: function(zoomDetails) {
1917
- if (this._map._mapPane.classList.contains("leaflet-touching")) {
1918
- return;
1919
- }
1920
- this._map.off("zoomanim", this._unspiderfyZoomAnim, this);
1921
- this._unspiderfy(zoomDetails);
1084
+ _unspiderfyZoomAnim: function(t) {
1085
+ this._map._mapPane.classList.contains("leaflet-touching") || (this._map.off("zoomanim", this._unspiderfyZoomAnim, this), this._unspiderfy(t));
1922
1086
  },
1923
1087
  _unspiderfyWrapper: function() {
1924
1088
  this._unspiderfy();
1925
1089
  },
1926
- _unspiderfy: function(zoomDetails) {
1927
- if (this._spiderfied) {
1928
- this._spiderfied.unspiderfy(zoomDetails);
1929
- }
1090
+ _unspiderfy: function(t) {
1091
+ this._spiderfied && this._spiderfied.unspiderfy(t);
1930
1092
  },
1931
1093
  _noanimationUnspiderfy: function() {
1932
- if (this._spiderfied) {
1933
- this._spiderfied._noanimationUnspiderfy();
1934
- }
1094
+ this._spiderfied && this._spiderfied._noanimationUnspiderfy();
1935
1095
  },
1936
1096
  //If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc
1937
- _unspiderfyLayer: function(layer) {
1938
- if (layer._spiderLeg) {
1939
- this._featureGroup.removeLayer(layer);
1940
- if (layer.clusterShow) {
1941
- layer.clusterShow();
1942
- }
1943
- if (layer.setZIndexOffset) {
1944
- layer.setZIndexOffset(0);
1945
- }
1946
- this._map.removeLayer(layer._spiderLeg);
1947
- delete layer._spiderLeg;
1948
- }
1097
+ _unspiderfyLayer: function(t) {
1098
+ t._spiderLeg && (this._featureGroup.removeLayer(t), t.clusterShow && t.clusterShow(), t.setZIndexOffset && t.setZIndexOffset(0), this._map.removeLayer(t._spiderLeg), delete t._spiderLeg);
1949
1099
  }
1950
1100
  });
1951
- L.MarkerClusterGroup.include({
1101
+ u.MarkerClusterGroup.include({
1952
1102
  /**
1953
1103
  * Updates the icon of all clusters which are parents of the given marker(s).
1954
1104
  * In singleMarkerMode, also updates the given marker(s) icon.
@@ -1957,39 +1107,19 @@ L.MarkerClusterGroup.include({
1957
1107
  * clusters need to be updated. If not provided, retrieves all child markers of this.
1958
1108
  * @returns {L.MarkerClusterGroup}
1959
1109
  */
1960
- refreshClusters: function(layers) {
1961
- if (!layers) {
1962
- layers = this._topClusterLevel.getAllChildMarkers();
1963
- } else if (layers instanceof L.MarkerClusterGroup) {
1964
- layers = layers._topClusterLevel.getAllChildMarkers();
1965
- } else if (layers instanceof L.LayerGroup) {
1966
- layers = layers._layers;
1967
- } else if (layers instanceof L.MarkerCluster) {
1968
- layers = layers.getAllChildMarkers();
1969
- } else if (layers instanceof L.Marker) {
1970
- layers = [layers];
1971
- }
1972
- this._flagParentsIconsNeedUpdate(layers);
1973
- this._refreshClustersIcons();
1974
- if (this.options.singleMarkerMode) {
1975
- this._refreshSingleMarkerModeMarkers(layers);
1976
- }
1977
- return this;
1110
+ refreshClusters: function(t) {
1111
+ return t ? t instanceof u.MarkerClusterGroup ? t = t._topClusterLevel.getAllChildMarkers() : t instanceof u.LayerGroup ? t = t._layers : t instanceof u.MarkerCluster ? t = t.getAllChildMarkers() : t instanceof u.Marker && (t = [t]) : t = this._topClusterLevel.getAllChildMarkers(), this._flagParentsIconsNeedUpdate(t), this._refreshClustersIcons(), this.options.singleMarkerMode && this._refreshSingleMarkerModeMarkers(t), this;
1978
1112
  },
1979
1113
  /**
1980
1114
  * Simply flags all parent clusters of the given markers as having a "dirty" icon.
1981
1115
  * @param layers Array(L.Marker)|Map(L.Marker) list of markers.
1982
1116
  * @private
1983
1117
  */
1984
- _flagParentsIconsNeedUpdate: (layers) => {
1985
- var id, parent;
1986
- for (id in layers) {
1987
- parent = layers[id].__parent;
1988
- while (parent) {
1989
- parent._iconNeedsUpdate = true;
1990
- parent = parent.__parent;
1991
- }
1992
- }
1118
+ _flagParentsIconsNeedUpdate: (t) => {
1119
+ var e, i;
1120
+ for (e in t)
1121
+ for (i = t[e].__parent; i; )
1122
+ i._iconNeedsUpdate = !0, i = i.__parent;
1993
1123
  },
1994
1124
  /**
1995
1125
  * Re-draws the icon of the supplied markers.
@@ -1997,17 +1127,13 @@ L.MarkerClusterGroup.include({
1997
1127
  * @param layers Array(L.Marker)|Map(L.Marker) list of markers.
1998
1128
  * @private
1999
1129
  */
2000
- _refreshSingleMarkerModeMarkers: function(layers) {
2001
- var id, layer;
2002
- for (id in layers) {
2003
- layer = layers[id];
2004
- if (this.hasLayer(layer)) {
2005
- layer.setIcon(this._overrideMarkerIcon(layer));
2006
- }
2007
- }
1130
+ _refreshSingleMarkerModeMarkers: function(t) {
1131
+ var e, i;
1132
+ for (e in t)
1133
+ i = t[e], this.hasLayer(i) && i.setIcon(this._overrideMarkerIcon(i));
2008
1134
  }
2009
1135
  });
2010
- L.Marker.include({
1136
+ u.Marker.include({
2011
1137
  /**
2012
1138
  * Updates the given options in the marker's icon and refreshes the marker.
2013
1139
  * @param options map object of icon options.
@@ -2015,14 +1141,9 @@ L.Marker.include({
2015
1141
  * MCG.refreshClustersOf() right away with this single marker.
2016
1142
  * @returns {L.Marker}
2017
1143
  */
2018
- refreshIconOptions: function(options, directlyRefreshClusters) {
2019
- var icon = this.options.icon;
2020
- L.setOptions(icon, options);
2021
- this.setIcon(icon);
2022
- if (directlyRefreshClusters && this.__parent) {
2023
- this.__parent._group.refreshClusters(this);
2024
- }
2025
- return this;
1144
+ refreshIconOptions: function(t, e) {
1145
+ var i = this.options.icon;
1146
+ return u.setOptions(i, t), this.setIcon(i), e && this.__parent && this.__parent._group.refreshClusters(this), this;
2026
1147
  }
2027
1148
  });
2028
1149
  //# sourceMappingURL=cluster.js.map