@mattilsynet/design 2.2.19 → 2.2.21
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.
- package/mtds/atlas/atlas-element.d.ts +7 -5
- package/mtds/atlas/atlas-element.js +70 -38
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas.css.js +27 -9
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas/atlas.stories.d.ts +4 -1
- package/mtds/atlas/cluster.js +1149 -0
- package/mtds/atlas/cluster.js.map +1 -0
- package/mtds/atlas.iife.js +629 -685
- package/mtds/atlas.js +4 -2
- package/mtds/atlas.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet-src.js +6265 -0
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -0
- package/mtds/external/leaflet/dist/leaflet.css.js +607 -0
- package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -0
- package/mtds/index.iife.js +12 -12
- package/mtds/package.json.js +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +43 -43
- package/mtds/styles.module.css.js +53 -53
- package/mtds/tabs/tabs.stories.d.ts +1 -0
- package/mtds/utils.d.ts +1 -1
- package/mtds/utils.js +9 -9
- package/mtds/utils.js.map +1 -1
- package/package.json +5 -6
- package/mtds/atlas/atlas.d.ts +0 -14
|
@@ -0,0 +1,1149 @@
|
|
|
1
|
+
import u from "../external/leaflet/dist/leaflet-src.js";
|
|
2
|
+
u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
3
|
+
options: {
|
|
4
|
+
maxClusterRadius: 80,
|
|
5
|
+
//A cluster will cover at most this many pixels from its center
|
|
6
|
+
iconCreateFunction: null,
|
|
7
|
+
spiderfyOnMaxZoom: !0,
|
|
8
|
+
showCoverageOnHover: !0,
|
|
9
|
+
zoomToBoundsOnClick: !0,
|
|
10
|
+
singleMarkerMode: !1,
|
|
11
|
+
disableClusteringAtZoom: null,
|
|
12
|
+
// Setting this to false prevents the removal of any clusters outside of the viewpoint, which
|
|
13
|
+
// is the default behaviour for performance reasons.
|
|
14
|
+
removeOutsideVisibleBounds: !0,
|
|
15
|
+
// Set to false to disable all animations (zoom and spiderfy).
|
|
16
|
+
// If false, option animateAddingMarkers below has no effect.
|
|
17
|
+
// If L.DomUtil.TRANSITION is falsy, this option has no effect.
|
|
18
|
+
animate: !0,
|
|
19
|
+
//Whether to animate adding markers after adding the MarkerClusterGroup to the map
|
|
20
|
+
// If you are adding individual markers set to true, if adding bulk markers leave false for massive performance gains.
|
|
21
|
+
animateAddingMarkers: !1,
|
|
22
|
+
//Increase to increase the distance away that spiderfied markers appear from the center
|
|
23
|
+
spiderfyDistanceMultiplier: 1,
|
|
24
|
+
// Make it possible to specify a polyline options on a spider leg
|
|
25
|
+
spiderLegPolylineOptions: { weight: 1.5, color: "#222", opacity: 0.5 },
|
|
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: !1,
|
|
28
|
+
chunkInterval: 200,
|
|
29
|
+
// process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback)
|
|
30
|
+
chunkDelay: 50,
|
|
31
|
+
// at the end of each interval, give n milliseconds back to system/browser
|
|
32
|
+
chunkProgress: null,
|
|
33
|
+
// progress callback: function(processed, total, elapsed) (e.g. for a progress indicator)
|
|
34
|
+
//Options to pass to the L.Polygon constructor
|
|
35
|
+
polygonOptions: {}
|
|
36
|
+
},
|
|
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 = {
|
|
39
|
+
dragstart: this._childMarkerDragStart,
|
|
40
|
+
move: this._childMarkerMoved,
|
|
41
|
+
dragend: this._childMarkerDragEnd
|
|
42
|
+
};
|
|
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))
|
|
54
|
+
return this;
|
|
55
|
+
this._unspiderfy && this._unspiderfy(), this._addLayer(t, this._maxZoom), this.fire("layeradd", { layer: 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;
|
|
61
|
+
},
|
|
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);
|
|
64
|
+
},
|
|
65
|
+
//Takes an array of markers and adds them in bulk
|
|
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;
|
|
69
|
+
if (this._map) {
|
|
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;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!l.getLatLng) {
|
|
77
|
+
n.addLayer(l), e || this.fire("layeradd", { layer: l, propagatedFrom: l });
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
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);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
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);
|
|
90
|
+
};
|
|
91
|
+
p();
|
|
92
|
+
} else {
|
|
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;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!l.getLatLng) {
|
|
100
|
+
n.addLayer(l);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
this.hasLayer(l) || d.push(l);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return this;
|
|
107
|
+
},
|
|
108
|
+
//Takes an array of markers and removes them in bulk
|
|
109
|
+
removeLayers: function(t) {
|
|
110
|
+
var e, i, n = t.length, s = this._featureGroup, o = this._nonPointGroup, r = !0;
|
|
111
|
+
if (!this._map) {
|
|
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;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
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 });
|
|
118
|
+
}
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
if (this._unspiderfy) {
|
|
122
|
+
this._unspiderfy();
|
|
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;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
this._unspiderfyLayer(i);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
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;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (!i.__parent) {
|
|
139
|
+
o.removeLayer(i), this.fire("layerremove", { layer: i, propagatedFrom: i });
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
this._removeLayer(i, !0, !0), this.fire("layerremove", { layer: i, propagatedFrom: i }), s.hasLayer(i) && (s.removeLayer(i), i.clusterShow && i.clusterShow());
|
|
143
|
+
}
|
|
144
|
+
return this._topClusterLevel._recalculateBounds(), this._refreshClustersIcons(), this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
145
|
+
null,
|
|
146
|
+
this._zoom,
|
|
147
|
+
this._currentShownBounds
|
|
148
|
+
), this;
|
|
149
|
+
},
|
|
150
|
+
//Removes all layers from the MarkerClusterGroup
|
|
151
|
+
clearLayers: function() {
|
|
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;
|
|
155
|
+
},
|
|
156
|
+
//Override FeatureGroup.getBounds as it doesn't work
|
|
157
|
+
getBounds: function() {
|
|
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;
|
|
163
|
+
},
|
|
164
|
+
//Overrides LayerGroup.eachLayer
|
|
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;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
s && t.call(e, i[o]);
|
|
174
|
+
}
|
|
175
|
+
this._nonPointGroup.eachLayer(t, e);
|
|
176
|
+
},
|
|
177
|
+
//Overrides LayerGroup.getLayers
|
|
178
|
+
getLayers: function() {
|
|
179
|
+
var t = [];
|
|
180
|
+
return this.eachLayer((e) => {
|
|
181
|
+
t.push(e);
|
|
182
|
+
}), t;
|
|
183
|
+
},
|
|
184
|
+
//Overrides LayerGroup.getLayer, WARNING: Really bad performance
|
|
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;
|
|
190
|
+
},
|
|
191
|
+
//Returns true if the given layer is in this MarkerClusterGroup
|
|
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);
|
|
203
|
+
},
|
|
204
|
+
//Zoom down to show the given layer (spiderfying if necessary) then calls the callback
|
|
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()));
|
|
210
|
+
};
|
|
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());
|
|
212
|
+
},
|
|
213
|
+
//Overrides FeatureGroup.onAdd
|
|
214
|
+
onAdd: function(t) {
|
|
215
|
+
this._map = t;
|
|
216
|
+
var e, i, n;
|
|
217
|
+
if (!Number.isFinite(this._map.getMaxZoom()))
|
|
218
|
+
throw "Map has no maxZoom specified";
|
|
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);
|
|
224
|
+
},
|
|
225
|
+
//Overrides FeatureGroup.onRemove
|
|
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(
|
|
228
|
+
" leaflet-cluster-anim",
|
|
229
|
+
""
|
|
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;
|
|
236
|
+
},
|
|
237
|
+
//Remove the given object from the given array
|
|
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;
|
|
242
|
+
},
|
|
243
|
+
/**
|
|
244
|
+
* Removes a marker from all _gridUnclustered zoom levels, starting at the supplied zoom.
|
|
245
|
+
* @param marker to be removed from _gridUnclustered.
|
|
246
|
+
* @param z integer bottom start zoom level (included)
|
|
247
|
+
* @private
|
|
248
|
+
*/
|
|
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
|
+
;
|
|
255
|
+
},
|
|
256
|
+
_childMarkerDragStart: (t) => {
|
|
257
|
+
t.target.__dragStart = t.target._latlng;
|
|
258
|
+
},
|
|
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();
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
_moveChild: function(t, e, i) {
|
|
266
|
+
t._latlng = e, this.removeLayer(t), t._latlng = i, this.addLayer(t);
|
|
267
|
+
},
|
|
268
|
+
_childMarkerDragEnd: function(t) {
|
|
269
|
+
t.target.__dragStart && this._moveChild(t.target, t.target.__dragStart, t.target._latlng), delete t.target.__dragStart;
|
|
270
|
+
},
|
|
271
|
+
//Internal function for removing a marker from everything.
|
|
272
|
+
//dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions)
|
|
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;
|
|
293
|
+
},
|
|
294
|
+
//Override L.Evented.fire
|
|
295
|
+
fire: function(t, e, i) {
|
|
296
|
+
if (e && e.propagatedFrom instanceof u.MarkerCluster) {
|
|
297
|
+
if (e.originalEvent && this._isOrIsParent(
|
|
298
|
+
e.propagatedFrom._icon,
|
|
299
|
+
e.originalEvent.relatedTarget
|
|
300
|
+
))
|
|
301
|
+
return;
|
|
302
|
+
t = `cluster${t}`;
|
|
303
|
+
}
|
|
304
|
+
u.FeatureGroup.prototype.fire.call(this, t, e, i);
|
|
305
|
+
},
|
|
306
|
+
//Override L.Evented.listens
|
|
307
|
+
listens: function(t, e) {
|
|
308
|
+
return u.FeatureGroup.prototype.listens.call(this, t, e) || u.FeatureGroup.prototype.listens.call(this, `cluster${t}`, e);
|
|
309
|
+
},
|
|
310
|
+
//Default functionality
|
|
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)
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
_bindEvents: function() {
|
|
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)));
|
|
337
|
+
},
|
|
338
|
+
_hideCoverage: function() {
|
|
339
|
+
this._shownPolygon && (this._map.removeLayer(this._shownPolygon), this._shownPolygon = null);
|
|
340
|
+
},
|
|
341
|
+
_unbindEvents: function() {
|
|
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));
|
|
344
|
+
},
|
|
345
|
+
_zoomEnd: function() {
|
|
346
|
+
this._map && (this._mergeSplitClusters(), this._zoom = Math.round(this._map._zoom), this._currentShownBounds = this._getExpandedVisibleBounds());
|
|
347
|
+
},
|
|
348
|
+
_moveEnd: function() {
|
|
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;
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
_generateInitialClusters: function() {
|
|
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);
|
|
369
|
+
},
|
|
370
|
+
//Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)
|
|
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;
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
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)
|
|
393
|
+
);
|
|
394
|
+
h._addChild(l), this._removeFromGridUnclustered(a, e);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
n[e].addObject(t, o);
|
|
398
|
+
}
|
|
399
|
+
this._topClusterLevel._addChild(t), t.__parent = this._topClusterLevel;
|
|
400
|
+
},
|
|
401
|
+
/**
|
|
402
|
+
* Refreshes the icon of all "dirty" visible clusters.
|
|
403
|
+
* Non-visible "dirty" clusters will be updated when they are added to the map.
|
|
404
|
+
* @private
|
|
405
|
+
*/
|
|
406
|
+
_refreshClustersIcons: function() {
|
|
407
|
+
this._featureGroup.eachLayer((t) => {
|
|
408
|
+
t instanceof u.MarkerCluster && t._iconNeedsUpdate && t._updateIcon();
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
//Enqueue code to fire after the marker expand/contract has happened
|
|
412
|
+
_enqueue: function(t) {
|
|
413
|
+
this._queue.push(t), this._queueTimeout || (this._queueTimeout = setTimeout(() => this._processQueue(), 300));
|
|
414
|
+
},
|
|
415
|
+
_processQueue: function() {
|
|
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;
|
|
419
|
+
},
|
|
420
|
+
//Merge and split any existing clusters that are too big or small
|
|
421
|
+
_mergeSplitClusters: function() {
|
|
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();
|
|
429
|
+
},
|
|
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)
|
|
431
|
+
_getExpandedVisibleBounds: function() {
|
|
432
|
+
if (this.options.removeOutsideVisibleBounds) {
|
|
433
|
+
if (u.Browser.mobile)
|
|
434
|
+
return this._checkBoundsMaxLat(this._map.getBounds());
|
|
435
|
+
} else return this._mapBoundsInfinite;
|
|
436
|
+
return this._checkBoundsMaxLat(this._map.getBounds().pad(1));
|
|
437
|
+
},
|
|
438
|
+
/**
|
|
439
|
+
* Expands the latitude to Infinity (or -Infinity) if the input bounds reach the map projection maximum defined latitude
|
|
440
|
+
* (in the case of Web/Spherical Mercator, it is 85.0511287798 / see https://en.wikipedia.org/wiki/Web_Mercator#Formulas).
|
|
441
|
+
* Otherwise, the removeOutsideVisibleBounds option will remove markers beyond that limit, whereas the same markers without
|
|
442
|
+
* this option (or outside MCG) will have their position floored (ceiled) by the projection and rendered at that limit,
|
|
443
|
+
* making the user think that MCG "eats" them and never displays them again.
|
|
444
|
+
* @param bounds L.LatLngBounds
|
|
445
|
+
* @returns {L.LatLngBounds}
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
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;
|
|
451
|
+
},
|
|
452
|
+
//Shared animation code
|
|
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();
|
|
462
|
+
},
|
|
463
|
+
/**
|
|
464
|
+
* Extracts individual (i.e. non-group) layers from a Layer Group.
|
|
465
|
+
* @param group to extract layers from.
|
|
466
|
+
* @param output {Array} in which to store the extracted layers.
|
|
467
|
+
* @returns {*|Array}
|
|
468
|
+
* @private
|
|
469
|
+
*/
|
|
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);
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
e.push(s);
|
|
478
|
+
}
|
|
479
|
+
return e;
|
|
480
|
+
},
|
|
481
|
+
/**
|
|
482
|
+
* Implements the singleMarkerMode option.
|
|
483
|
+
* @param layer Marker to re-style using the Clusters iconCreateFunction.
|
|
484
|
+
* @returns {L.Icon} The newly created icon.
|
|
485
|
+
* @private
|
|
486
|
+
*/
|
|
487
|
+
_overrideMarkerIcon: function(t) {
|
|
488
|
+
return t.options.icon = this.options.iconCreateFunction({
|
|
489
|
+
getChildCount: () => 1,
|
|
490
|
+
getAllChildMarkers: () => [t]
|
|
491
|
+
}), t.options.icon;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
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)
|
|
498
|
+
)
|
|
499
|
+
});
|
|
500
|
+
u.MarkerClusterGroup.include({
|
|
501
|
+
_noAnimation: {
|
|
502
|
+
//Non Animated versions of everything
|
|
503
|
+
_animationStart: () => {
|
|
504
|
+
},
|
|
505
|
+
_animationZoomIn: function(t, e) {
|
|
506
|
+
this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
507
|
+
this._currentShownBounds,
|
|
508
|
+
Math.floor(this._map.getMinZoom()),
|
|
509
|
+
t
|
|
510
|
+
), this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
511
|
+
null,
|
|
512
|
+
e,
|
|
513
|
+
this._getExpandedVisibleBounds()
|
|
514
|
+
), this.fire("animationend");
|
|
515
|
+
},
|
|
516
|
+
_animationZoomOut: function(t, e) {
|
|
517
|
+
this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
518
|
+
this._currentShownBounds,
|
|
519
|
+
Math.floor(this._map.getMinZoom()),
|
|
520
|
+
t
|
|
521
|
+
), this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
522
|
+
null,
|
|
523
|
+
e,
|
|
524
|
+
this._getExpandedVisibleBounds()
|
|
525
|
+
), this.fire("animationend");
|
|
526
|
+
},
|
|
527
|
+
_animationAddLayer: function(t, e) {
|
|
528
|
+
this._animationAddLayerNonAnimated(t, e);
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
_withAnimation: {
|
|
532
|
+
//Animated versions here
|
|
533
|
+
_animationStart: function() {
|
|
534
|
+
this._map._mapPane.className += " leaflet-cluster-anim", this._inZoomAnimation++;
|
|
535
|
+
},
|
|
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(_);
|
|
546
|
+
}
|
|
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);
|
|
555
|
+
}
|
|
556
|
+
), this._ignoreMove = !1, this._enqueue(function() {
|
|
557
|
+
this._topClusterLevel._recursively(
|
|
558
|
+
i,
|
|
559
|
+
t,
|
|
560
|
+
s,
|
|
561
|
+
(r) => {
|
|
562
|
+
n.removeLayer(r), r.clusterShow();
|
|
563
|
+
}
|
|
564
|
+
), this._animationEnd();
|
|
565
|
+
});
|
|
566
|
+
},
|
|
567
|
+
_animationZoomOut: function(t, e) {
|
|
568
|
+
this._animationZoomOutSingle(
|
|
569
|
+
this._topClusterLevel,
|
|
570
|
+
t - 1,
|
|
571
|
+
e
|
|
572
|
+
), this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
573
|
+
null,
|
|
574
|
+
e,
|
|
575
|
+
this._getExpandedVisibleBounds()
|
|
576
|
+
), this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
577
|
+
this._currentShownBounds,
|
|
578
|
+
Math.floor(this._map.getMinZoom()),
|
|
579
|
+
t,
|
|
580
|
+
this._getExpandedVisibleBounds()
|
|
581
|
+
);
|
|
582
|
+
},
|
|
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
|
+
)));
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
// Private methods for animated versions.
|
|
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
|
|
602
|
+
);
|
|
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
|
|
614
|
+
);
|
|
615
|
+
});
|
|
616
|
+
o._animationEnd();
|
|
617
|
+
});
|
|
618
|
+
},
|
|
619
|
+
_animationEnd: function() {
|
|
620
|
+
this._map && (this._map._mapPane.className = this._map._mapPane.className.replace(
|
|
621
|
+
" leaflet-cluster-anim",
|
|
622
|
+
""
|
|
623
|
+
)), this._inZoomAnimation--, this.fire("animationend");
|
|
624
|
+
},
|
|
625
|
+
//Force a browser layout of stuff in the map
|
|
626
|
+
// Should apply the current opacity and location to all elements so we can update them again for an animation
|
|
627
|
+
_forceLayout: () => {
|
|
628
|
+
u.Util.falseFn(document.body.offsetWidth);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
u.MarkerCluster = u.Marker.extend({
|
|
632
|
+
initialize: function(t, e, i, n) {
|
|
633
|
+
u.Marker.prototype.initialize.call(
|
|
634
|
+
this,
|
|
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);
|
|
638
|
+
},
|
|
639
|
+
//Recursively retrieve all child markers of this cluster
|
|
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;
|
|
647
|
+
},
|
|
648
|
+
//Returns the count of how many child markers we have
|
|
649
|
+
getChildCount: function() {
|
|
650
|
+
return this._childCount;
|
|
651
|
+
},
|
|
652
|
+
//Zoom to the minimum of showing all of the child markers, or the extents of this cluster
|
|
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;
|
|
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);
|
|
662
|
+
},
|
|
663
|
+
getBounds: function() {
|
|
664
|
+
var t = new u.LatLngBounds();
|
|
665
|
+
return t.extend(this._bounds), t;
|
|
666
|
+
},
|
|
667
|
+
_updateIcon: function() {
|
|
668
|
+
this._iconNeedsUpdate = !0, this._icon && this.setIcon(this);
|
|
669
|
+
},
|
|
670
|
+
//Cludge for Icon, we pretend to be an icon for performance
|
|
671
|
+
createIcon: function() {
|
|
672
|
+
return this._iconNeedsUpdate && (this._iconObj = this._group.options.iconCreateFunction(this), this._iconNeedsUpdate = !1), this._iconObj.createIcon();
|
|
673
|
+
},
|
|
674
|
+
createShadow: function() {
|
|
675
|
+
return this._iconObj.createShadow();
|
|
676
|
+
},
|
|
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);
|
|
679
|
+
},
|
|
680
|
+
/**
|
|
681
|
+
* Makes sure the cluster center is set. If not, uses the child center if it is a cluster, or the marker position.
|
|
682
|
+
* @param child L.MarkerCluster|L.Marker that will be used as cluster center if not defined yet.
|
|
683
|
+
* @private
|
|
684
|
+
*/
|
|
685
|
+
_setClusterCenter: function(t) {
|
|
686
|
+
this._cLatLng || (this._cLatLng = t._cLatLng || t._latlng);
|
|
687
|
+
},
|
|
688
|
+
/**
|
|
689
|
+
* Assigns impossible bounding values so that the next extend entirely determines the new bounds.
|
|
690
|
+
* This method avoids having to trash the previous L.LatLngBounds object and to create a new one, which is much slower for this class.
|
|
691
|
+
* As long as the bounds are not extended, most other methods would probably fail, as they would with bounds initialized but not extended.
|
|
692
|
+
* @private
|
|
693
|
+
*/
|
|
694
|
+
_resetBounds: function() {
|
|
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);
|
|
697
|
+
},
|
|
698
|
+
_recalculateBounds: function() {
|
|
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;
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
//Set our markers position as given and add it to the map
|
|
712
|
+
_addToMap: function(t) {
|
|
713
|
+
t && (this._backupLatlng = this._latlng, this.setLatLng(t)), this._group._featureGroup.addLayer(this);
|
|
714
|
+
},
|
|
715
|
+
_recursivelyAnimateChildrenIn: function(t, e, i) {
|
|
716
|
+
this._recursively(
|
|
717
|
+
t,
|
|
718
|
+
this._group._map.getMinZoom(),
|
|
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());
|
|
724
|
+
},
|
|
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());
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
},
|
|
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();
|
|
743
|
+
});
|
|
744
|
+
},
|
|
745
|
+
_recursivelyBecomeVisible: function(t, e) {
|
|
746
|
+
this._recursively(
|
|
747
|
+
t,
|
|
748
|
+
this._group._map.getMinZoom(),
|
|
749
|
+
e,
|
|
750
|
+
null,
|
|
751
|
+
(i) => {
|
|
752
|
+
i.clusterShow();
|
|
753
|
+
}
|
|
754
|
+
);
|
|
755
|
+
},
|
|
756
|
+
_recursivelyAddChildrenToMap: function(t, e, i) {
|
|
757
|
+
this._recursively(
|
|
758
|
+
i,
|
|
759
|
+
this._group._map.getMinZoom() - 1,
|
|
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));
|
|
766
|
+
}
|
|
767
|
+
},
|
|
768
|
+
(n) => {
|
|
769
|
+
n._addToMap(t);
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
},
|
|
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);
|
|
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);
|
|
784
|
+
},
|
|
785
|
+
_restorePosition: function() {
|
|
786
|
+
this._backupLatlng && (this.setLatLng(this._backupLatlng), delete this._backupLatlng);
|
|
787
|
+
},
|
|
788
|
+
//exceptBounds: If set, don't remove any markers/clusters in it
|
|
789
|
+
_recursivelyRemoveChildrenFromMap: function(t, e, i, n) {
|
|
790
|
+
var s, o;
|
|
791
|
+
this._recursively(
|
|
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());
|
|
798
|
+
},
|
|
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());
|
|
802
|
+
}
|
|
803
|
+
);
|
|
804
|
+
},
|
|
805
|
+
//Run the given functions recursively to this and child clusters
|
|
806
|
+
// boundsToApplyTo: a L.LatLngBounds representing the bounds of what clusters to recurse in to
|
|
807
|
+
// zoomLevelToStart: zoom level to start running functions (inclusive)
|
|
808
|
+
// zoomLevelToStop: zoom level to stop running functions (inclusive)
|
|
809
|
+
// runAtEveryLevel: function that takes an L.MarkerCluster as an argument that should be applied on every level
|
|
810
|
+
// runAtBottomLevel: function that takes an L.MarkerCluster as an argument that should be applied at only the bottom level
|
|
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
|
+
);
|
|
822
|
+
},
|
|
823
|
+
//Returns true if we are the parent of only one cluster and that cluster is the same as us
|
|
824
|
+
_isSingleParent: function() {
|
|
825
|
+
return this._childClusters.length > 0 && this._childClusters[0]._childCount === this._childCount;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
u.Marker.include({
|
|
829
|
+
clusterHide: function() {
|
|
830
|
+
return this.options.opacityWhenUnclustered = this.options.opacity || 1, this.setOpacity(0);
|
|
831
|
+
},
|
|
832
|
+
clusterShow: function() {
|
|
833
|
+
var t = this.setOpacity(
|
|
834
|
+
this.options.opacity || this.options.opacityWhenUnclustered
|
|
835
|
+
);
|
|
836
|
+
return delete this.options.opacityWhenUnclustered, t;
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
u.DistanceGrid = function(t) {
|
|
840
|
+
this._cellSize = t, this._sqCellSize = t * t, this._grid = {}, this._objectPoint = {};
|
|
841
|
+
};
|
|
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);
|
|
853
|
+
},
|
|
854
|
+
//Returns true if the object was found
|
|
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);
|
|
919
|
+
}
|
|
920
|
+
return { maxPoint: n, newPoints: s };
|
|
921
|
+
},
|
|
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;
|
|
956
|
+
}
|
|
957
|
+
};
|
|
958
|
+
u.MarkerCluster.include({
|
|
959
|
+
getConvexHull: function() {
|
|
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);
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
u.MarkerCluster.include({
|
|
967
|
+
_2PI: Math.PI * 2,
|
|
968
|
+
_circleFootSeparation: 25,
|
|
969
|
+
//related to circumference of circle
|
|
970
|
+
_circleStartAngle: Math.PI / 6,
|
|
971
|
+
_spiralFootSeparation: 28,
|
|
972
|
+
//related to size of spiral (experiment!)
|
|
973
|
+
_spiralLengthStart: 11,
|
|
974
|
+
_spiralLengthFactor: 5,
|
|
975
|
+
_circleSpiralSwitchover: 9,
|
|
976
|
+
//show spiral instead of circle from this marker count upwards.
|
|
977
|
+
// 0 -> always spiral; Infinity -> always circle
|
|
978
|
+
spiderfy: function() {
|
|
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);
|
|
982
|
+
}
|
|
983
|
+
},
|
|
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)
|
|
993
|
+
)._round();
|
|
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;
|
|
1004
|
+
},
|
|
1005
|
+
_noanimationUnspiderfy: function() {
|
|
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", {
|
|
1010
|
+
cluster: this,
|
|
1011
|
+
markers: n
|
|
1012
|
+
}), t._ignoreMove = !1, t._spiderfied = null;
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
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", {
|
|
1021
|
+
cluster: this,
|
|
1022
|
+
markers: t
|
|
1023
|
+
});
|
|
1024
|
+
},
|
|
1025
|
+
_animationUnspiderfy: function() {
|
|
1026
|
+
this._noanimationUnspiderfy();
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
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(
|
|
1032
|
+
{},
|
|
1033
|
+
this._group.options.spiderLegPolylineOptions
|
|
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", {
|
|
1041
|
+
cluster: this,
|
|
1042
|
+
markers: t
|
|
1043
|
+
});
|
|
1044
|
+
}, 200);
|
|
1045
|
+
},
|
|
1046
|
+
_animationUnspiderfy: function(t) {
|
|
1047
|
+
var e = this._group, i = e._map, n = e._featureGroup, s = t ? i._latLngToNewLayerPoint(
|
|
1048
|
+
this._latlng,
|
|
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", {
|
|
1061
|
+
cluster: this,
|
|
1062
|
+
markers: o
|
|
1063
|
+
});
|
|
1064
|
+
}, 200);
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
u.MarkerClusterGroup.include({
|
|
1068
|
+
//The MarkerCluster currently spiderfied (if any)
|
|
1069
|
+
_spiderfied: null,
|
|
1070
|
+
unspiderfy: function(...t) {
|
|
1071
|
+
this._unspiderfy.apply(this, t);
|
|
1072
|
+
},
|
|
1073
|
+
_spiderfierOnAdd: function() {
|
|
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);
|
|
1075
|
+
},
|
|
1076
|
+
_spiderfierOnRemove: function() {
|
|
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();
|
|
1078
|
+
},
|
|
1079
|
+
//On zoom start we add a zoomanim handler so that we are guaranteed to be last (after markers are animated)
|
|
1080
|
+
//This means we can define the animation they do rather than Markers doing an animation to their actual location
|
|
1081
|
+
_unspiderfyZoomStart: function() {
|
|
1082
|
+
this._map && this._map.on("zoomanim", this._unspiderfyZoomAnim, this);
|
|
1083
|
+
},
|
|
1084
|
+
_unspiderfyZoomAnim: function(t) {
|
|
1085
|
+
this._map._mapPane.classList.contains("leaflet-touching") || (this._map.off("zoomanim", this._unspiderfyZoomAnim, this), this._unspiderfy(t));
|
|
1086
|
+
},
|
|
1087
|
+
_unspiderfyWrapper: function() {
|
|
1088
|
+
this._unspiderfy();
|
|
1089
|
+
},
|
|
1090
|
+
_unspiderfy: function(t) {
|
|
1091
|
+
this._spiderfied && this._spiderfied.unspiderfy(t);
|
|
1092
|
+
},
|
|
1093
|
+
_noanimationUnspiderfy: function() {
|
|
1094
|
+
this._spiderfied && this._spiderfied._noanimationUnspiderfy();
|
|
1095
|
+
},
|
|
1096
|
+
//If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc
|
|
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);
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
u.MarkerClusterGroup.include({
|
|
1102
|
+
/**
|
|
1103
|
+
* Updates the icon of all clusters which are parents of the given marker(s).
|
|
1104
|
+
* In singleMarkerMode, also updates the given marker(s) icon.
|
|
1105
|
+
* @param layers L.MarkerClusterGroup|L.LayerGroup|Array(L.Marker)|Map(L.Marker)|
|
|
1106
|
+
* L.MarkerCluster|L.Marker (optional) list of markers (or single marker) whose parent
|
|
1107
|
+
* clusters need to be updated. If not provided, retrieves all child markers of this.
|
|
1108
|
+
* @returns {L.MarkerClusterGroup}
|
|
1109
|
+
*/
|
|
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;
|
|
1112
|
+
},
|
|
1113
|
+
/**
|
|
1114
|
+
* Simply flags all parent clusters of the given markers as having a "dirty" icon.
|
|
1115
|
+
* @param layers Array(L.Marker)|Map(L.Marker) list of markers.
|
|
1116
|
+
* @private
|
|
1117
|
+
*/
|
|
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;
|
|
1123
|
+
},
|
|
1124
|
+
/**
|
|
1125
|
+
* Re-draws the icon of the supplied markers.
|
|
1126
|
+
* To be used in singleMarkerMode only.
|
|
1127
|
+
* @param layers Array(L.Marker)|Map(L.Marker) list of markers.
|
|
1128
|
+
* @private
|
|
1129
|
+
*/
|
|
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));
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
u.Marker.include({
|
|
1137
|
+
/**
|
|
1138
|
+
* Updates the given options in the marker's icon and refreshes the marker.
|
|
1139
|
+
* @param options map object of icon options.
|
|
1140
|
+
* @param directlyRefreshClusters boolean (optional) true to trigger
|
|
1141
|
+
* MCG.refreshClustersOf() right away with this single marker.
|
|
1142
|
+
* @returns {L.Marker}
|
|
1143
|
+
*/
|
|
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;
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1149
|
+
//# sourceMappingURL=cluster.js.map
|