@mattilsynet/design 2.2.24 → 2.2.25
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/alert/alert.js +9 -8
- package/mtds/alert/alert.js.map +1 -1
- package/mtds/analytics/analytics.d.ts +1 -1
- package/mtds/analytics/analytics.js +163 -101
- package/mtds/analytics/analytics.js.map +1 -1
- package/mtds/app/app-observer.js +73 -27
- package/mtds/app/app-observer.js.map +1 -1
- package/mtds/app/app-toggle.js +2 -24
- package/mtds/app/app-toggle.js.map +1 -1
- package/mtds/app/app-toggle2.js +16 -10
- package/mtds/app/app-toggle2.js.map +1 -1
- package/mtds/app/app.d.ts +5 -5
- package/mtds/app/app.js +36 -32
- package/mtds/app/app.js.map +1 -1
- package/mtds/atlas/atlas-element.d.ts +8 -14
- package/mtds/atlas/atlas-element.js +90 -76
- package/mtds/atlas/atlas-element.js.map +1 -1
- package/mtds/atlas/atlas-marker.d.ts +20 -0
- package/mtds/atlas/atlas-marker.js +69 -0
- package/mtds/atlas/atlas-marker.js.map +1 -0
- package/mtds/atlas/atlas-matgeo.d.ts +29 -0
- package/mtds/atlas/atlas-matgeo.js +71 -0
- package/mtds/atlas/atlas-matgeo.js.map +1 -0
- package/mtds/atlas/atlas.css.js +76 -96
- package/mtds/atlas/atlas.css.js.map +1 -1
- package/mtds/atlas/atlas.d.ts +42 -0
- package/mtds/atlas/atlas.js +33 -0
- package/mtds/atlas/atlas.js.map +1 -0
- package/mtds/atlas/atlas.stories.d.ts +5 -1
- package/mtds/atlas/cluster.js +1576 -697
- package/mtds/atlas/cluster.js.map +1 -1
- package/mtds/atlas.iife.js +80 -100
- package/mtds/atlas.js +8 -4
- package/mtds/atlas.js.map +1 -1
- package/mtds/avatar/avatar.js +8 -8
- package/mtds/avatar/avatar.js.map +1 -1
- package/mtds/badge/badge.d.ts +2 -2
- package/mtds/badge/badge.js +7 -7
- package/mtds/badge/badge.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs-observer.js +10 -9
- package/mtds/breadcrumbs/breadcrumbs-observer.js.map +1 -1
- package/mtds/breadcrumbs/breadcrumbs.js +14 -13
- package/mtds/breadcrumbs/breadcrumbs.js.map +1 -1
- package/mtds/button/button.js +16 -14
- package/mtds/button/button.js.map +1 -1
- package/mtds/card/card.js +14 -12
- package/mtds/card/card.js.map +1 -1
- package/mtds/chart/chart-axis.js +27 -15
- package/mtds/chart/chart-axis.js.map +1 -1
- package/mtds/chart/chart-bars.js +15 -13
- package/mtds/chart/chart-bars.js.map +1 -1
- package/mtds/chart/chart-element.d.ts +5 -0
- package/mtds/chart/chart-element.js +83 -48
- package/mtds/chart/chart-element.js.map +1 -1
- package/mtds/chart/chart-lines.js +54 -32
- package/mtds/chart/chart-lines.js.map +1 -1
- package/mtds/chart/chart-pies.js +34 -14
- package/mtds/chart/chart-pies.js.map +1 -1
- package/mtds/chart/chart.css.js +2 -2
- package/mtds/chart/chart.css.js.map +1 -1
- package/mtds/chart/chart.d.ts +3 -4
- package/mtds/chart/chart.js +12 -12
- package/mtds/chart/chart.js.map +1 -1
- package/mtds/chip/chip.js +8 -8
- package/mtds/chip/chip.js.map +1 -1
- package/mtds/details/details.d.ts +3 -3
- package/mtds/details/details.js +14 -12
- package/mtds/details/details.js.map +1 -1
- package/mtds/dialog/dialog-observer.js +35 -22
- package/mtds/dialog/dialog-observer.js.map +1 -1
- package/mtds/dialog/dialog.d.ts +2 -2
- package/mtds/dialog/dialog.js +12 -12
- package/mtds/dialog/dialog.js.map +1 -1
- package/mtds/divider/divider.d.ts +2 -2
- package/mtds/divider/divider.js +10 -10
- package/mtds/divider/divider.js.map +1 -1
- package/mtds/errorsummary/errorsummary-observer.js +11 -8
- package/mtds/errorsummary/errorsummary-observer.js.map +1 -1
- package/mtds/errorsummary/errorsummary.d.ts +1 -1
- package/mtds/errorsummary/errorsummary.js +11 -11
- package/mtds/errorsummary/errorsummary.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet-src.js +6006 -3098
- package/mtds/external/leaflet/dist/leaflet-src.js.map +1 -1
- package/mtds/external/leaflet/dist/leaflet.css.js +2 -2
- package/mtds/external/leaflet/dist/leaflet.css.js.map +1 -1
- package/mtds/field/field-observer.js +114 -62
- package/mtds/field/field-observer.js.map +1 -1
- package/mtds/field/field.d.ts +6 -6
- package/mtds/field/field.js +166 -133
- package/mtds/field/field.js.map +1 -1
- package/mtds/field/field.stories.d.ts +2 -0
- package/mtds/fieldset/fieldset-observer.js +24 -14
- package/mtds/fieldset/fieldset-observer.js.map +1 -1
- package/mtds/fieldset/fieldset.d.ts +1 -1
- package/mtds/fieldset/fieldset.js +11 -11
- package/mtds/fieldset/fieldset.js.map +1 -1
- package/mtds/fileupload/fileupload.js +9 -8
- package/mtds/fileupload/fileupload.js.map +1 -1
- package/mtds/helptext/helptext.d.ts +1 -1
- package/mtds/helptext/helptext.js +15 -15
- package/mtds/helptext/helptext.js.map +1 -1
- package/mtds/index.iife.js +9 -9
- package/mtds/index.js +26 -24
- package/mtds/input/input.d.ts +3 -3
- package/mtds/input/input.js +22 -20
- package/mtds/input/input.js.map +1 -1
- package/mtds/law/law-helper.d.ts +6 -2
- package/mtds/law/law-helper.js +145 -63
- package/mtds/law/law-helper.js.map +1 -1
- package/mtds/law/law.d.ts +6 -2
- package/mtds/law/law.js +6 -6
- package/mtds/law/law.js.map +1 -1
- package/mtds/law/law.stories.d.ts +1 -0
- package/mtds/layout/layout.js +13 -10
- package/mtds/layout/layout.js.map +1 -1
- package/mtds/link/link.js +8 -7
- package/mtds/link/link.js.map +1 -1
- package/mtds/logo/logo-observer.js +18 -12
- package/mtds/logo/logo-observer.js.map +1 -1
- package/mtds/logo/logo.js +8 -8
- package/mtds/logo/logo.js.map +1 -1
- package/mtds/package.json.js +2 -2
- package/mtds/pagination/pagination-helper.js +17 -11
- package/mtds/pagination/pagination-helper.js.map +1 -1
- package/mtds/pagination/pagination.d.ts +1 -1
- package/mtds/pagination/pagination.js +30 -30
- package/mtds/pagination/pagination.js.map +1 -1
- package/mtds/popover/popover-observer.js +37 -28
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/popover/popover.js +13 -11
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/progress/progress.d.ts +1 -1
- package/mtds/progress/progress.js +8 -8
- package/mtds/progress/progress.js.map +1 -1
- package/mtds/react-atlas.d.ts +1 -0
- package/mtds/react-atlas.js +13 -0
- package/mtds/react-atlas.js.map +1 -0
- package/mtds/react-types.d.ts +3 -0
- package/mtds/react.js +79 -79
- package/mtds/skeleton/skeleton.js +8 -8
- package/mtds/skeleton/skeleton.js.map +1 -1
- package/mtds/spinner/spinner.d.ts +2 -2
- package/mtds/spinner/spinner.js +8 -8
- package/mtds/spinner/spinner.js.map +1 -1
- package/mtds/steps/steps.d.ts +2 -2
- package/mtds/steps/steps.js +7 -7
- package/mtds/steps/steps.js.map +1 -1
- package/mtds/styles.css +4586 -1
- package/mtds/styles.module.css.js +167 -112
- package/mtds/styles.module.css.js.map +1 -1
- package/mtds/table/table-observer.js +22 -19
- package/mtds/table/table-observer.js.map +1 -1
- package/mtds/table/table.d.ts +4 -4
- package/mtds/table/table.js +18 -16
- package/mtds/table/table.js.map +1 -1
- package/mtds/tabs/tabs.d.ts +4 -4
- package/mtds/tabs/tabs.js +25 -21
- package/mtds/tabs/tabs.js.map +1 -1
- package/mtds/tag/tag.js +8 -8
- package/mtds/tag/tag.js.map +1 -1
- package/mtds/tailwind.css +24 -6
- package/mtds/toast/toast-helper.js +35 -20
- package/mtds/toast/toast-helper.js.map +1 -1
- package/mtds/toast/toast-observer.js +30 -15
- package/mtds/toast/toast-observer.js.map +1 -1
- package/mtds/toast/toast.js +45 -37
- package/mtds/toast/toast.js.map +1 -1
- package/mtds/togglegroup/togglegroup-observer.js +15 -10
- package/mtds/togglegroup/togglegroup-observer.js.map +1 -1
- package/mtds/togglegroup/togglegroup.d.ts +3 -3
- package/mtds/togglegroup/togglegroup.js +20 -18
- package/mtds/togglegroup/togglegroup.js.map +1 -1
- package/mtds/tooltip/tooltip-observer.js +48 -32
- package/mtds/tooltip/tooltip-observer.js.map +1 -1
- package/mtds/typography/typography.js +28 -19
- package/mtds/typography/typography.js.map +1 -1
- package/mtds/utils.d.ts +12 -3
- package/mtds/utils.js +133 -81
- package/mtds/utils.js.map +1 -1
- package/mtds/validation/validation.d.ts +1 -1
- package/mtds/validation/validation.js +12 -12
- package/mtds/validation/validation.js.map +1 -1
- package/package.json +14 -10
package/mtds/atlas/cluster.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import L from "../external/leaflet/dist/leaflet-src.js";
|
|
2
|
+
L.MarkerClusterGroup = L.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:
|
|
8
|
-
showCoverageOnHover:
|
|
9
|
-
zoomToBoundsOnClick:
|
|
10
|
-
singleMarkerMode:
|
|
7
|
+
spiderfyOnMaxZoom: true,
|
|
8
|
+
showCoverageOnHover: true,
|
|
9
|
+
zoomToBoundsOnClick: true,
|
|
10
|
+
singleMarkerMode: false,
|
|
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:
|
|
14
|
+
removeOutsideVisibleBounds: true,
|
|
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:
|
|
18
|
+
animate: true,
|
|
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:
|
|
21
|
+
animateAddingMarkers: false,
|
|
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:
|
|
27
|
+
chunkedLoading: false,
|
|
28
28
|
chunkInterval: 200,
|
|
29
29
|
// process markers for a maximum of ~ n milliseconds (then trigger the chunkProgress callback)
|
|
30
30
|
chunkDelay: 50,
|
|
@@ -34,211 +34,457 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
34
34
|
//Options to pass to the L.Polygon constructor
|
|
35
35
|
polygonOptions: {}
|
|
36
36
|
},
|
|
37
|
-
initialize: function(
|
|
38
|
-
|
|
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 = {
|
|
39
55
|
dragstart: this._childMarkerDragStart,
|
|
40
56
|
move: this._childMarkerMoved,
|
|
41
57
|
dragend: this._childMarkerDragEnd
|
|
42
58
|
};
|
|
43
|
-
var
|
|
44
|
-
Object.assign(this,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
|
|
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 });
|
|
54
70
|
return this;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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;
|
|
61
101
|
},
|
|
62
|
-
removeLayer: function(
|
|
63
|
-
|
|
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;
|
|
64
137
|
},
|
|
65
138
|
//Takes an array of markers and adds them in bulk
|
|
66
|
-
addLayers: function(
|
|
67
|
-
if (!Array.isArray(
|
|
68
|
-
var
|
|
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;
|
|
69
142
|
if (this._map) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
161
|
continue;
|
|
75
162
|
}
|
|
76
|
-
if (!
|
|
77
|
-
|
|
163
|
+
if (!m.getLatLng) {
|
|
164
|
+
npg.addLayer(m);
|
|
165
|
+
if (!skipLayerAddEvent) {
|
|
166
|
+
this.fire("layeradd", { layer: m, propagatedFrom: m });
|
|
167
|
+
}
|
|
78
168
|
continue;
|
|
79
169
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
}
|
|
83
183
|
}
|
|
84
184
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
+
}
|
|
90
199
|
};
|
|
91
|
-
|
|
200
|
+
process();
|
|
92
201
|
} else {
|
|
93
|
-
const
|
|
94
|
-
for (;
|
|
95
|
-
|
|
96
|
-
|
|
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);
|
|
97
216
|
continue;
|
|
98
217
|
}
|
|
99
|
-
if (
|
|
100
|
-
n.addLayer(l);
|
|
218
|
+
if (this.hasLayer(m)) {
|
|
101
219
|
continue;
|
|
102
220
|
}
|
|
103
|
-
|
|
221
|
+
needsClustering.push(m);
|
|
104
222
|
}
|
|
105
223
|
}
|
|
106
224
|
return this;
|
|
107
225
|
},
|
|
108
226
|
//Takes an array of markers and removes them in bulk
|
|
109
|
-
removeLayers: function(
|
|
110
|
-
var
|
|
227
|
+
removeLayers: function(layersArray) {
|
|
228
|
+
var i, m, l = layersArray.length, fg = this._featureGroup, npg = this._nonPointGroup, originalArray = true;
|
|
111
229
|
if (!this._map) {
|
|
112
|
-
for (
|
|
113
|
-
|
|
114
|
-
|
|
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;
|
|
115
239
|
continue;
|
|
116
240
|
}
|
|
117
|
-
this._arraySplice(this._needsClustering,
|
|
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 });
|
|
118
247
|
}
|
|
119
248
|
return this;
|
|
120
249
|
}
|
|
121
250
|
if (this._unspiderfy) {
|
|
122
251
|
this._unspiderfy();
|
|
123
|
-
const
|
|
124
|
-
let
|
|
125
|
-
for (
|
|
126
|
-
|
|
127
|
-
|
|
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;
|
|
128
259
|
continue;
|
|
129
260
|
}
|
|
130
|
-
this._unspiderfyLayer(
|
|
261
|
+
this._unspiderfyLayer(m);
|
|
131
262
|
}
|
|
132
263
|
}
|
|
133
|
-
for (
|
|
134
|
-
|
|
135
|
-
|
|
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;
|
|
136
273
|
continue;
|
|
137
274
|
}
|
|
138
|
-
if (!
|
|
139
|
-
|
|
275
|
+
if (!m.__parent) {
|
|
276
|
+
npg.removeLayer(m);
|
|
277
|
+
this.fire("layerremove", { layer: m, propagatedFrom: m });
|
|
140
278
|
continue;
|
|
141
279
|
}
|
|
142
|
-
this._removeLayer(
|
|
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
|
+
}
|
|
143
288
|
}
|
|
144
|
-
|
|
289
|
+
this._topClusterLevel._recalculateBounds();
|
|
290
|
+
this._refreshClustersIcons();
|
|
291
|
+
this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
145
292
|
null,
|
|
146
293
|
this._zoom,
|
|
147
294
|
this._currentShownBounds
|
|
148
|
-
)
|
|
295
|
+
);
|
|
296
|
+
return this;
|
|
149
297
|
},
|
|
150
298
|
//Removes all layers from the MarkerClusterGroup
|
|
151
299
|
clearLayers: function() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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;
|
|
155
318
|
},
|
|
156
319
|
//Override FeatureGroup.getBounds as it doesn't work
|
|
157
320
|
getBounds: function() {
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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;
|
|
163
330
|
},
|
|
164
331
|
//Overrides LayerGroup.eachLayer
|
|
165
|
-
eachLayer: function(
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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;
|
|
171
342
|
break;
|
|
172
343
|
}
|
|
173
|
-
|
|
344
|
+
}
|
|
345
|
+
if (thisNeedsRemoving) {
|
|
346
|
+
method.call(context, markers[i]);
|
|
347
|
+
}
|
|
174
348
|
}
|
|
175
|
-
this._nonPointGroup.eachLayer(
|
|
349
|
+
this._nonPointGroup.eachLayer(method, context);
|
|
176
350
|
},
|
|
177
351
|
//Overrides LayerGroup.getLayers
|
|
178
352
|
getLayers: function() {
|
|
179
|
-
var
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
})
|
|
353
|
+
var layers = [];
|
|
354
|
+
this.eachLayer((l) => {
|
|
355
|
+
layers.push(l);
|
|
356
|
+
});
|
|
357
|
+
return layers;
|
|
183
358
|
},
|
|
184
359
|
//Overrides LayerGroup.getLayer, WARNING: Really bad performance
|
|
185
|
-
getLayer: function(
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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;
|
|
190
369
|
},
|
|
191
370
|
//Returns true if the given layer is in this MarkerClusterGroup
|
|
192
|
-
hasLayer: function(
|
|
193
|
-
if (!
|
|
194
|
-
return
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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);
|
|
203
388
|
},
|
|
204
389
|
//Zoom down to show the given layer (spiderfying if necessary) then calls the callback
|
|
205
|
-
zoomToShowLayer: function(
|
|
206
|
-
typeof
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
+
}
|
|
210
406
|
};
|
|
211
|
-
|
|
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
|
+
}
|
|
212
417
|
},
|
|
213
418
|
//Overrides FeatureGroup.onAdd
|
|
214
|
-
onAdd: function(
|
|
215
|
-
this._map =
|
|
216
|
-
var
|
|
217
|
-
if (!Number.isFinite(this._map.getMaxZoom()))
|
|
419
|
+
onAdd: function(map) {
|
|
420
|
+
this._map = map;
|
|
421
|
+
var i, l, layer;
|
|
422
|
+
if (!Number.isFinite(this._map.getMaxZoom())) {
|
|
218
423
|
throw "Map has no maxZoom specified";
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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);
|
|
224
453
|
},
|
|
225
454
|
//Overrides FeatureGroup.onRemove
|
|
226
|
-
onRemove: function(
|
|
227
|
-
|
|
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(
|
|
228
460
|
" leaflet-cluster-anim",
|
|
229
461
|
""
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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;
|
|
236
479
|
},
|
|
237
480
|
//Remove the given object from the given array
|
|
238
|
-
_arraySplice: (
|
|
239
|
-
for (let i =
|
|
240
|
-
if (
|
|
241
|
-
|
|
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
|
+
}
|
|
242
488
|
},
|
|
243
489
|
/**
|
|
244
490
|
* Removes a marker from all _gridUnclustered zoom levels, starting at the supplied zoom.
|
|
@@ -246,157 +492,269 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
246
492
|
* @param z integer bottom start zoom level (included)
|
|
247
493
|
* @private
|
|
248
494
|
*/
|
|
249
|
-
_removeFromGridUnclustered: function(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
+
}
|
|
255
505
|
},
|
|
256
|
-
_childMarkerDragStart: (
|
|
257
|
-
|
|
506
|
+
_childMarkerDragStart: (e) => {
|
|
507
|
+
e.target.__dragStart = e.target._latlng;
|
|
258
508
|
},
|
|
259
|
-
_childMarkerMoved: function(
|
|
260
|
-
if (!this._ignoreMove && !
|
|
261
|
-
const
|
|
262
|
-
this._moveChild(
|
|
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
|
+
}
|
|
263
516
|
}
|
|
264
517
|
},
|
|
265
|
-
_moveChild: function(
|
|
266
|
-
|
|
518
|
+
_moveChild: function(layer, from, to) {
|
|
519
|
+
layer._latlng = from;
|
|
520
|
+
this.removeLayer(layer);
|
|
521
|
+
layer._latlng = to;
|
|
522
|
+
this.addLayer(layer);
|
|
267
523
|
},
|
|
268
|
-
_childMarkerDragEnd: function(
|
|
269
|
-
|
|
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;
|
|
270
529
|
},
|
|
271
530
|
//Internal function for removing a marker from everything.
|
|
272
531
|
//dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions)
|
|
273
|
-
_removeLayer: function(
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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;
|
|
293
576
|
},
|
|
294
577
|
//Override L.Evented.fire
|
|
295
|
-
fire: function(
|
|
296
|
-
if (e && e.propagatedFrom instanceof
|
|
578
|
+
fire: function(type, e, propagate) {
|
|
579
|
+
if (e && e.propagatedFrom instanceof L.MarkerCluster) {
|
|
297
580
|
if (e.originalEvent && this._isOrIsParent(
|
|
298
581
|
e.propagatedFrom._icon,
|
|
299
582
|
e.originalEvent.relatedTarget
|
|
300
583
|
))
|
|
301
584
|
return;
|
|
302
|
-
|
|
585
|
+
type = `cluster${type}`;
|
|
303
586
|
}
|
|
304
|
-
|
|
587
|
+
L.FeatureGroup.prototype.fire.call(this, type, e, propagate);
|
|
305
588
|
},
|
|
306
589
|
//Override L.Evented.listens
|
|
307
|
-
listens: function(
|
|
308
|
-
return
|
|
590
|
+
listens: function(type, propagate) {
|
|
591
|
+
return L.FeatureGroup.prototype.listens.call(this, type, propagate) || L.FeatureGroup.prototype.listens.call(this, `cluster${type}`, propagate);
|
|
309
592
|
},
|
|
310
593
|
//Default functionality
|
|
311
|
-
_defaultIconCreateFunction: (
|
|
312
|
-
const
|
|
313
|
-
let
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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)
|
|
318
608
|
});
|
|
319
609
|
},
|
|
320
610
|
_bindEvents: function() {
|
|
321
|
-
var
|
|
322
|
-
(
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
+
}
|
|
337
651
|
},
|
|
338
652
|
_hideCoverage: function() {
|
|
339
|
-
|
|
653
|
+
if (this._shownPolygon) {
|
|
654
|
+
this._map.removeLayer(this._shownPolygon);
|
|
655
|
+
this._shownPolygon = null;
|
|
656
|
+
}
|
|
340
657
|
},
|
|
341
658
|
_unbindEvents: function() {
|
|
342
|
-
var
|
|
343
|
-
(
|
|
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
|
+
}
|
|
344
668
|
},
|
|
345
669
|
_zoomEnd: function() {
|
|
346
|
-
|
|
670
|
+
if (!this._map) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
this._mergeSplitClusters();
|
|
674
|
+
this._zoom = Math.round(this._map._zoom);
|
|
675
|
+
this._currentShownBounds = this._getExpandedVisibleBounds();
|
|
347
676
|
},
|
|
348
677
|
_moveEnd: function() {
|
|
349
|
-
if (
|
|
350
|
-
|
|
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;
|
|
678
|
+
if (this._inZoomAnimation) {
|
|
679
|
+
return;
|
|
361
680
|
}
|
|
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;
|
|
362
695
|
},
|
|
363
696
|
_generateInitialClusters: function() {
|
|
364
|
-
var
|
|
365
|
-
typeof
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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);
|
|
369
712
|
},
|
|
370
713
|
//Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom)
|
|
371
|
-
_addLayer: function(
|
|
372
|
-
var
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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;
|
|
378
726
|
return;
|
|
379
727
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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)
|
|
393
747
|
);
|
|
394
|
-
|
|
748
|
+
}
|
|
749
|
+
parent._addChild(lastParent);
|
|
750
|
+
this._removeFromGridUnclustered(closest, zoom);
|
|
395
751
|
return;
|
|
396
752
|
}
|
|
397
|
-
|
|
753
|
+
gridUnclustered[zoom].addObject(layer, markerPoint);
|
|
398
754
|
}
|
|
399
|
-
this._topClusterLevel._addChild(
|
|
755
|
+
this._topClusterLevel._addChild(layer);
|
|
756
|
+
layer.__parent = this._topClusterLevel;
|
|
757
|
+
return;
|
|
400
758
|
},
|
|
401
759
|
/**
|
|
402
760
|
* Refreshes the icon of all "dirty" visible clusters.
|
|
@@ -404,35 +762,54 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
404
762
|
* @private
|
|
405
763
|
*/
|
|
406
764
|
_refreshClustersIcons: function() {
|
|
407
|
-
this._featureGroup.eachLayer((
|
|
408
|
-
|
|
765
|
+
this._featureGroup.eachLayer((c) => {
|
|
766
|
+
if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
|
|
767
|
+
c._updateIcon();
|
|
768
|
+
}
|
|
409
769
|
});
|
|
410
770
|
},
|
|
411
771
|
//Enqueue code to fire after the marker expand/contract has happened
|
|
412
|
-
_enqueue: function(
|
|
413
|
-
this._queue.push(
|
|
772
|
+
_enqueue: function(fn) {
|
|
773
|
+
this._queue.push(fn);
|
|
774
|
+
if (!this._queueTimeout) {
|
|
775
|
+
this._queueTimeout = setTimeout(() => this._processQueue(), 300);
|
|
776
|
+
}
|
|
414
777
|
},
|
|
415
778
|
_processQueue: function() {
|
|
416
|
-
for (let
|
|
417
|
-
this._queue[
|
|
418
|
-
|
|
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;
|
|
419
785
|
},
|
|
420
786
|
//Merge and split any existing clusters that are too big or small
|
|
421
787
|
_mergeSplitClusters: function() {
|
|
422
|
-
var
|
|
423
|
-
this._processQueue()
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
this.
|
|
427
|
-
|
|
428
|
-
|
|
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
|
+
}
|
|
429
805
|
},
|
|
430
806
|
//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
807
|
_getExpandedVisibleBounds: function() {
|
|
432
|
-
if (this.options.removeOutsideVisibleBounds) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
808
|
+
if (!this.options.removeOutsideVisibleBounds) {
|
|
809
|
+
return this._mapBoundsInfinite;
|
|
810
|
+
} else if (L.Browser.mobile) {
|
|
811
|
+
return this._checkBoundsMaxLat(this._map.getBounds());
|
|
812
|
+
}
|
|
436
813
|
return this._checkBoundsMaxLat(this._map.getBounds().pad(1));
|
|
437
814
|
},
|
|
438
815
|
/**
|
|
@@ -445,20 +822,30 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
445
822
|
* @returns {L.LatLngBounds}
|
|
446
823
|
* @private
|
|
447
824
|
*/
|
|
448
|
-
_checkBoundsMaxLat: function(
|
|
449
|
-
var
|
|
450
|
-
|
|
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;
|
|
451
836
|
},
|
|
452
837
|
//Shared animation code
|
|
453
|
-
_animationAddLayerNonAnimated: function(
|
|
454
|
-
if (
|
|
455
|
-
this._featureGroup.addLayer(
|
|
456
|
-
else if (
|
|
457
|
-
|
|
458
|
-
const
|
|
459
|
-
this._featureGroup.removeLayer(
|
|
460
|
-
|
|
461
|
-
|
|
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
|
+
}
|
|
462
849
|
},
|
|
463
850
|
/**
|
|
464
851
|
* Extracts individual (i.e. non-group) layers from a Layer Group.
|
|
@@ -467,16 +854,18 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
467
854
|
* @returns {*|Array}
|
|
468
855
|
* @private
|
|
469
856
|
*/
|
|
470
|
-
_extractNonGroupLayers: function(
|
|
471
|
-
var
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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);
|
|
475
864
|
continue;
|
|
476
865
|
}
|
|
477
|
-
|
|
866
|
+
output.push(layer);
|
|
478
867
|
}
|
|
479
|
-
return
|
|
868
|
+
return output;
|
|
480
869
|
},
|
|
481
870
|
/**
|
|
482
871
|
* Implements the singleMarkerMode option.
|
|
@@ -484,206 +873,318 @@ u.MarkerClusterGroup = u.FeatureGroup.extend({
|
|
|
484
873
|
* @returns {L.Icon} The newly created icon.
|
|
485
874
|
* @private
|
|
486
875
|
*/
|
|
487
|
-
_overrideMarkerIcon: function(
|
|
488
|
-
|
|
876
|
+
_overrideMarkerIcon: function(layer) {
|
|
877
|
+
layer.options.icon = this.options.iconCreateFunction({
|
|
489
878
|
getChildCount: () => 1,
|
|
490
|
-
getAllChildMarkers: () => [
|
|
491
|
-
})
|
|
879
|
+
getAllChildMarkers: () => [layer]
|
|
880
|
+
});
|
|
881
|
+
return layer.options.icon;
|
|
492
882
|
}
|
|
493
883
|
});
|
|
494
|
-
|
|
495
|
-
_mapBoundsInfinite: new
|
|
496
|
-
new
|
|
497
|
-
new
|
|
884
|
+
L.MarkerClusterGroup.include({
|
|
885
|
+
_mapBoundsInfinite: new L.LatLngBounds(
|
|
886
|
+
new L.LatLng(-Infinity, -Infinity),
|
|
887
|
+
new L.LatLng(Infinity, Infinity)
|
|
498
888
|
)
|
|
499
889
|
});
|
|
500
|
-
|
|
890
|
+
L.MarkerClusterGroup.include({
|
|
501
891
|
_noAnimation: {
|
|
502
892
|
//Non Animated versions of everything
|
|
503
893
|
_animationStart: () => {
|
|
504
894
|
},
|
|
505
|
-
_animationZoomIn: function(
|
|
895
|
+
_animationZoomIn: function(previousZoomLevel, newZoomLevel) {
|
|
506
896
|
this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
507
897
|
this._currentShownBounds,
|
|
508
898
|
Math.floor(this._map.getMinZoom()),
|
|
509
|
-
|
|
510
|
-
)
|
|
899
|
+
previousZoomLevel
|
|
900
|
+
);
|
|
901
|
+
this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
511
902
|
null,
|
|
512
|
-
|
|
903
|
+
newZoomLevel,
|
|
513
904
|
this._getExpandedVisibleBounds()
|
|
514
|
-
)
|
|
905
|
+
);
|
|
906
|
+
this.fire("animationend");
|
|
515
907
|
},
|
|
516
|
-
_animationZoomOut: function(
|
|
908
|
+
_animationZoomOut: function(previousZoomLevel, newZoomLevel) {
|
|
517
909
|
this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
518
910
|
this._currentShownBounds,
|
|
519
911
|
Math.floor(this._map.getMinZoom()),
|
|
520
|
-
|
|
521
|
-
)
|
|
912
|
+
previousZoomLevel
|
|
913
|
+
);
|
|
914
|
+
this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
522
915
|
null,
|
|
523
|
-
|
|
916
|
+
newZoomLevel,
|
|
524
917
|
this._getExpandedVisibleBounds()
|
|
525
|
-
)
|
|
918
|
+
);
|
|
919
|
+
this.fire("animationend");
|
|
526
920
|
},
|
|
527
|
-
_animationAddLayer: function(
|
|
528
|
-
this._animationAddLayerNonAnimated(
|
|
921
|
+
_animationAddLayer: function(layer, newCluster) {
|
|
922
|
+
this._animationAddLayerNonAnimated(layer, newCluster);
|
|
529
923
|
}
|
|
530
924
|
},
|
|
531
925
|
_withAnimation: {
|
|
532
926
|
//Animated versions here
|
|
533
927
|
_animationStart: function() {
|
|
534
|
-
this._map._mapPane.className += " leaflet-cluster-anim"
|
|
928
|
+
this._map._mapPane.className += " leaflet-cluster-anim";
|
|
929
|
+
this._inZoomAnimation++;
|
|
535
930
|
},
|
|
536
|
-
_animationZoomIn: function(
|
|
537
|
-
var
|
|
538
|
-
this._ignoreMove =
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
+
}
|
|
546
956
|
}
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
(r) => {
|
|
554
|
-
r._recursivelyRestoreChildPositions(e);
|
|
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();
|
|
555
963
|
}
|
|
556
|
-
)
|
|
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() {
|
|
557
975
|
this._topClusterLevel._recursively(
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
(
|
|
562
|
-
|
|
976
|
+
bounds,
|
|
977
|
+
previousZoomLevel,
|
|
978
|
+
minZoom,
|
|
979
|
+
(c) => {
|
|
980
|
+
fg.removeLayer(c);
|
|
981
|
+
c.clusterShow();
|
|
563
982
|
}
|
|
564
|
-
)
|
|
983
|
+
);
|
|
984
|
+
this._animationEnd();
|
|
565
985
|
});
|
|
566
986
|
},
|
|
567
|
-
_animationZoomOut: function(
|
|
987
|
+
_animationZoomOut: function(previousZoomLevel, newZoomLevel) {
|
|
568
988
|
this._animationZoomOutSingle(
|
|
569
989
|
this._topClusterLevel,
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
)
|
|
990
|
+
previousZoomLevel - 1,
|
|
991
|
+
newZoomLevel
|
|
992
|
+
);
|
|
993
|
+
this._topClusterLevel._recursivelyAddChildrenToMap(
|
|
573
994
|
null,
|
|
574
|
-
|
|
995
|
+
newZoomLevel,
|
|
575
996
|
this._getExpandedVisibleBounds()
|
|
576
|
-
)
|
|
997
|
+
);
|
|
998
|
+
this._topClusterLevel._recursivelyRemoveChildrenFromMap(
|
|
577
999
|
this._currentShownBounds,
|
|
578
1000
|
Math.floor(this._map.getMinZoom()),
|
|
579
|
-
|
|
1001
|
+
previousZoomLevel,
|
|
580
1002
|
this._getExpandedVisibleBounds()
|
|
581
1003
|
);
|
|
582
1004
|
},
|
|
583
|
-
_animationAddLayer: function(
|
|
584
|
-
var
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
+
}
|
|
592
1030
|
}
|
|
593
1031
|
},
|
|
594
1032
|
// Private methods for animated versions.
|
|
595
|
-
_animationZoomOutSingle: function(
|
|
596
|
-
var
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
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
|
|
602
1040
|
);
|
|
603
|
-
var
|
|
604
|
-
this._forceLayout()
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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
|
|
614
1059
|
);
|
|
615
1060
|
});
|
|
616
|
-
|
|
1061
|
+
}
|
|
1062
|
+
me._animationEnd();
|
|
617
1063
|
});
|
|
618
1064
|
},
|
|
619
1065
|
_animationEnd: function() {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
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");
|
|
624
1074
|
},
|
|
625
1075
|
//Force a browser layout of stuff in the map
|
|
626
1076
|
// Should apply the current opacity and location to all elements so we can update them again for an animation
|
|
627
1077
|
_forceLayout: () => {
|
|
628
|
-
|
|
1078
|
+
L.Util.falseFn(document.body.offsetWidth);
|
|
629
1079
|
}
|
|
630
1080
|
});
|
|
631
|
-
|
|
632
|
-
initialize: function(
|
|
633
|
-
|
|
1081
|
+
L.MarkerCluster = L.Marker.extend({
|
|
1082
|
+
initialize: function(group, zoom, a, b) {
|
|
1083
|
+
L.Marker.prototype.initialize.call(
|
|
634
1084
|
this,
|
|
635
|
-
|
|
636
|
-
{ icon: this, pane:
|
|
637
|
-
)
|
|
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
|
+
}
|
|
638
1102
|
},
|
|
639
1103
|
//Recursively retrieve all child markers of this cluster
|
|
640
|
-
getAllChildMarkers: function(
|
|
641
|
-
|
|
642
|
-
for (let
|
|
643
|
-
this._childClusters[
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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;
|
|
647
1113
|
},
|
|
648
1114
|
//Returns the count of how many child markers we have
|
|
649
1115
|
getChildCount: function() {
|
|
650
1116
|
return this._childCount;
|
|
651
1117
|
},
|
|
652
1118
|
//Zoom to the minimum of showing all of the child markers, or the extents of this cluster
|
|
653
|
-
zoomToBounds: function(
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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);
|
|
660
1135
|
}
|
|
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
1136
|
},
|
|
663
1137
|
getBounds: function() {
|
|
664
|
-
var
|
|
665
|
-
|
|
1138
|
+
var bounds = new L.LatLngBounds();
|
|
1139
|
+
bounds.extend(this._bounds);
|
|
1140
|
+
return bounds;
|
|
666
1141
|
},
|
|
667
1142
|
_updateIcon: function() {
|
|
668
|
-
this._iconNeedsUpdate =
|
|
1143
|
+
this._iconNeedsUpdate = true;
|
|
1144
|
+
if (this._icon) {
|
|
1145
|
+
this.setIcon(this);
|
|
1146
|
+
}
|
|
669
1147
|
},
|
|
670
1148
|
//Cludge for Icon, we pretend to be an icon for performance
|
|
671
1149
|
createIcon: function() {
|
|
672
|
-
|
|
1150
|
+
if (this._iconNeedsUpdate) {
|
|
1151
|
+
this._iconObj = this._group.options.iconCreateFunction(this);
|
|
1152
|
+
this._iconNeedsUpdate = false;
|
|
1153
|
+
}
|
|
1154
|
+
return this._iconObj.createIcon();
|
|
673
1155
|
},
|
|
674
1156
|
createShadow: function() {
|
|
675
1157
|
return this._iconObj.createShadow();
|
|
676
1158
|
},
|
|
677
|
-
_addChild: function(
|
|
678
|
-
this._iconNeedsUpdate =
|
|
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
|
+
}
|
|
679
1178
|
},
|
|
680
1179
|
/**
|
|
681
1180
|
* Makes sure the cluster center is set. If not, uses the child center if it is a cluster, or the marker position.
|
|
682
1181
|
* @param child L.MarkerCluster|L.Marker that will be used as cluster center if not defined yet.
|
|
683
1182
|
* @private
|
|
684
1183
|
*/
|
|
685
|
-
_setClusterCenter: function(
|
|
686
|
-
|
|
1184
|
+
_setClusterCenter: function(child) {
|
|
1185
|
+
if (!this._cLatLng) {
|
|
1186
|
+
this._cLatLng = child._cLatLng || child._latlng;
|
|
1187
|
+
}
|
|
687
1188
|
},
|
|
688
1189
|
/**
|
|
689
1190
|
* Assigns impossible bounding values so that the next extend entirely determines the new bounds.
|
|
@@ -692,113 +1193,192 @@ u.MarkerCluster = u.Marker.extend({
|
|
|
692
1193
|
* @private
|
|
693
1194
|
*/
|
|
694
1195
|
_resetBounds: function() {
|
|
695
|
-
var
|
|
696
|
-
|
|
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
|
+
}
|
|
697
1205
|
},
|
|
698
1206
|
_recalculateBounds: function() {
|
|
699
|
-
var
|
|
700
|
-
if (
|
|
701
|
-
|
|
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;
|
|
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;
|
|
709
1210
|
}
|
|
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;
|
|
710
1234
|
},
|
|
711
1235
|
//Set our markers position as given and add it to the map
|
|
712
|
-
_addToMap: function(
|
|
713
|
-
|
|
1236
|
+
_addToMap: function(startPos) {
|
|
1237
|
+
if (startPos) {
|
|
1238
|
+
this._backupLatlng = this._latlng;
|
|
1239
|
+
this.setLatLng(startPos);
|
|
1240
|
+
}
|
|
1241
|
+
this._group._featureGroup.addLayer(this);
|
|
714
1242
|
},
|
|
715
|
-
_recursivelyAnimateChildrenIn: function(
|
|
1243
|
+
_recursivelyAnimateChildrenIn: function(bounds, center, maxZoom) {
|
|
716
1244
|
this._recursively(
|
|
717
|
-
|
|
1245
|
+
bounds,
|
|
718
1246
|
this._group._map.getMinZoom(),
|
|
719
|
-
|
|
720
|
-
(
|
|
721
|
-
var
|
|
722
|
-
for (
|
|
723
|
-
|
|
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
|
+
}
|
|
724
1257
|
},
|
|
725
|
-
(
|
|
726
|
-
var
|
|
727
|
-
for (
|
|
728
|
-
|
|
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
|
+
}
|
|
729
1267
|
}
|
|
730
1268
|
);
|
|
731
1269
|
},
|
|
732
|
-
_recursivelyAnimateChildrenInAndAddSelfToMap: function(
|
|
733
|
-
this._recursively(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
)
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
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();
|
|
743
1288
|
});
|
|
744
1289
|
},
|
|
745
|
-
_recursivelyBecomeVisible: function(
|
|
1290
|
+
_recursivelyBecomeVisible: function(bounds, zoomLevel) {
|
|
746
1291
|
this._recursively(
|
|
747
|
-
|
|
1292
|
+
bounds,
|
|
748
1293
|
this._group._map.getMinZoom(),
|
|
749
|
-
|
|
1294
|
+
zoomLevel,
|
|
750
1295
|
null,
|
|
751
|
-
(
|
|
752
|
-
|
|
1296
|
+
(c) => {
|
|
1297
|
+
c.clusterShow();
|
|
753
1298
|
}
|
|
754
1299
|
);
|
|
755
1300
|
},
|
|
756
|
-
_recursivelyAddChildrenToMap: function(
|
|
1301
|
+
_recursivelyAddChildrenToMap: function(startPos, zoomLevel, bounds) {
|
|
757
1302
|
this._recursively(
|
|
758
|
-
|
|
1303
|
+
bounds,
|
|
759
1304
|
this._group._map.getMinZoom() - 1,
|
|
760
|
-
|
|
761
|
-
(
|
|
762
|
-
if (
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
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
|
+
}
|
|
766
1321
|
}
|
|
1322
|
+
c._group._featureGroup.addLayer(nm);
|
|
1323
|
+
}
|
|
767
1324
|
},
|
|
768
|
-
(
|
|
769
|
-
|
|
1325
|
+
(c) => {
|
|
1326
|
+
c._addToMap(startPos);
|
|
770
1327
|
}
|
|
771
1328
|
);
|
|
772
1329
|
},
|
|
773
|
-
_recursivelyRestoreChildPositions: function(
|
|
774
|
-
for (let
|
|
775
|
-
const
|
|
776
|
-
|
|
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
|
+
}
|
|
777
1346
|
}
|
|
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
1347
|
},
|
|
785
1348
|
_restorePosition: function() {
|
|
786
|
-
|
|
1349
|
+
if (this._backupLatlng) {
|
|
1350
|
+
this.setLatLng(this._backupLatlng);
|
|
1351
|
+
delete this._backupLatlng;
|
|
1352
|
+
}
|
|
787
1353
|
},
|
|
788
1354
|
//exceptBounds: If set, don't remove any markers/clusters in it
|
|
789
|
-
_recursivelyRemoveChildrenFromMap: function(
|
|
790
|
-
var
|
|
1355
|
+
_recursivelyRemoveChildrenFromMap: function(previousBounds, mapMinZoom, zoomLevel, exceptBounds) {
|
|
1356
|
+
var m, i;
|
|
791
1357
|
this._recursively(
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
(
|
|
796
|
-
for (
|
|
797
|
-
|
|
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
|
+
}
|
|
798
1371
|
},
|
|
799
|
-
(
|
|
800
|
-
for (
|
|
801
|
-
|
|
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
|
+
}
|
|
802
1382
|
}
|
|
803
1383
|
);
|
|
804
1384
|
},
|
|
@@ -808,162 +1388,250 @@ u.MarkerCluster = u.Marker.extend({
|
|
|
808
1388
|
// zoomLevelToStop: zoom level to stop running functions (inclusive)
|
|
809
1389
|
// runAtEveryLevel: function that takes an L.MarkerCluster as an argument that should be applied on every level
|
|
810
1390
|
// runAtBottomLevel: function that takes an L.MarkerCluster as an argument that should be applied at only the bottom level
|
|
811
|
-
_recursively: function(
|
|
812
|
-
var
|
|
813
|
-
if (
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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
|
+
}
|
|
822
1415
|
},
|
|
823
1416
|
//Returns true if we are the parent of only one cluster and that cluster is the same as us
|
|
824
1417
|
_isSingleParent: function() {
|
|
825
1418
|
return this._childClusters.length > 0 && this._childClusters[0]._childCount === this._childCount;
|
|
826
1419
|
}
|
|
827
1420
|
});
|
|
828
|
-
|
|
1421
|
+
L.Marker.include({
|
|
829
1422
|
clusterHide: function() {
|
|
830
|
-
|
|
1423
|
+
this.options.opacityWhenUnclustered = this.options.opacity || 1;
|
|
1424
|
+
return this.setOpacity(0);
|
|
831
1425
|
},
|
|
832
1426
|
clusterShow: function() {
|
|
833
|
-
var
|
|
1427
|
+
var ret = this.setOpacity(
|
|
834
1428
|
this.options.opacity || this.options.opacityWhenUnclustered
|
|
835
1429
|
);
|
|
836
|
-
|
|
1430
|
+
delete this.options.opacityWhenUnclustered;
|
|
1431
|
+
return ret;
|
|
837
1432
|
}
|
|
838
1433
|
});
|
|
839
|
-
|
|
840
|
-
this._cellSize =
|
|
1434
|
+
L.DistanceGrid = function(cellSize) {
|
|
1435
|
+
this._cellSize = cellSize;
|
|
1436
|
+
this._sqCellSize = cellSize * cellSize;
|
|
1437
|
+
this._grid = {};
|
|
1438
|
+
this._objectPoint = {};
|
|
841
1439
|
};
|
|
842
|
-
|
|
843
|
-
addObject: function(
|
|
844
|
-
var
|
|
845
|
-
|
|
846
|
-
var
|
|
847
|
-
|
|
848
|
-
var
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
this.
|
|
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);
|
|
853
1456
|
},
|
|
854
1457
|
//Returns true if the object was found
|
|
855
|
-
removeObject: function(
|
|
856
|
-
var
|
|
857
|
-
|
|
858
|
-
var
|
|
859
|
-
|
|
860
|
-
var
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
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);
|
|
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
|
+
}
|
|
919
1476
|
}
|
|
920
|
-
return { maxPoint: n, newPoints: s };
|
|
921
1477
|
},
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
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
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
return closest;
|
|
1515
|
+
},
|
|
1516
|
+
_getCoord: function(x) {
|
|
1517
|
+
return Math.floor(x / this._cellSize);
|
|
1518
|
+
},
|
|
1519
|
+
_sqDist: (p, p2) => {
|
|
1520
|
+
var dx = p2.x - p.x, dy = p2.y - p.y;
|
|
1521
|
+
return dx * dx + dy * dy;
|
|
956
1522
|
}
|
|
957
1523
|
};
|
|
958
|
-
|
|
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({
|
|
959
1625
|
getConvexHull: function() {
|
|
960
|
-
var
|
|
961
|
-
for (
|
|
962
|
-
|
|
963
|
-
|
|
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);
|
|
964
1632
|
}
|
|
965
1633
|
});
|
|
966
|
-
|
|
1634
|
+
L.MarkerCluster.include({
|
|
967
1635
|
_2PI: Math.PI * 2,
|
|
968
1636
|
_circleFootSeparation: 25,
|
|
969
1637
|
//related to circumference of circle
|
|
@@ -976,129 +1644,311 @@ u.MarkerCluster.include({
|
|
|
976
1644
|
//show spiral instead of circle from this marker count upwards.
|
|
977
1645
|
// 0 -> always spiral; Infinity -> always circle
|
|
978
1646
|
spiderfy: function() {
|
|
979
|
-
if (
|
|
980
|
-
|
|
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);
|
|
1647
|
+
if (this._group._spiderfied === this || this._group._inZoomAnimation) {
|
|
1648
|
+
return;
|
|
982
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);
|
|
1658
|
+
}
|
|
1659
|
+
this._animationSpiderfy(childMarkers, positions);
|
|
983
1660
|
},
|
|
984
|
-
unspiderfy: function(
|
|
985
|
-
this._group._inZoomAnimation
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
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)
|
|
993
1676
|
)._round();
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
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)
|
|
1688
|
+
)._round();
|
|
1689
|
+
legLength += lengthFactor / angle;
|
|
1690
|
+
}
|
|
1691
|
+
return res;
|
|
1004
1692
|
},
|
|
1005
1693
|
_noanimationUnspiderfy: function() {
|
|
1006
|
-
var
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
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", {
|
|
1010
1713
|
cluster: this,
|
|
1011
|
-
markers:
|
|
1012
|
-
})
|
|
1714
|
+
markers: childMarkers
|
|
1715
|
+
});
|
|
1716
|
+
group._ignoreMove = false;
|
|
1717
|
+
group._spiderfied = null;
|
|
1013
1718
|
}
|
|
1014
1719
|
});
|
|
1015
|
-
|
|
1016
|
-
_animationSpiderfy: function(
|
|
1017
|
-
var
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
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", {
|
|
1021
1740
|
cluster: this,
|
|
1022
|
-
markers:
|
|
1741
|
+
markers: childMarkers
|
|
1023
1742
|
});
|
|
1024
1743
|
},
|
|
1025
1744
|
_animationUnspiderfy: function() {
|
|
1026
1745
|
this._noanimationUnspiderfy();
|
|
1027
1746
|
}
|
|
1028
1747
|
});
|
|
1029
|
-
|
|
1030
|
-
_animationSpiderfy: function(
|
|
1031
|
-
var
|
|
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(
|
|
1032
1751
|
{},
|
|
1033
1752
|
this._group.options.spiderLegPolylineOptions
|
|
1034
|
-
),
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
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", {
|
|
1041
1809
|
cluster: this,
|
|
1042
|
-
markers:
|
|
1810
|
+
markers: childMarkers
|
|
1043
1811
|
});
|
|
1044
1812
|
}, 200);
|
|
1045
1813
|
},
|
|
1046
|
-
_animationUnspiderfy: function(
|
|
1047
|
-
var
|
|
1814
|
+
_animationUnspiderfy: function(zoomDetails) {
|
|
1815
|
+
var group = this._group, map = group._map, fg = group._featureGroup, thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(
|
|
1048
1816
|
this._latlng,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
) :
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
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", {
|
|
1061
1879
|
cluster: this,
|
|
1062
|
-
markers:
|
|
1880
|
+
markers: childMarkers
|
|
1063
1881
|
});
|
|
1064
1882
|
}, 200);
|
|
1065
1883
|
}
|
|
1066
1884
|
});
|
|
1067
|
-
|
|
1885
|
+
L.MarkerClusterGroup.include({
|
|
1068
1886
|
//The MarkerCluster currently spiderfied (if any)
|
|
1069
1887
|
_spiderfied: null,
|
|
1070
|
-
unspiderfy: function(...
|
|
1071
|
-
this._unspiderfy.apply(this,
|
|
1888
|
+
unspiderfy: function(...args) {
|
|
1889
|
+
this._unspiderfy.apply(this, args);
|
|
1072
1890
|
},
|
|
1073
1891
|
_spiderfierOnAdd: function() {
|
|
1074
|
-
this._map.on("click", this._unspiderfyWrapper, this)
|
|
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
|
+
}
|
|
1075
1900
|
},
|
|
1076
1901
|
_spiderfierOnRemove: function() {
|
|
1077
|
-
this._map.off("click", this._unspiderfyWrapper, this)
|
|
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();
|
|
1078
1907
|
},
|
|
1079
1908
|
//On zoom start we add a zoomanim handler so that we are guaranteed to be last (after markers are animated)
|
|
1080
1909
|
//This means we can define the animation they do rather than Markers doing an animation to their actual location
|
|
1081
1910
|
_unspiderfyZoomStart: function() {
|
|
1082
|
-
|
|
1911
|
+
if (!this._map) {
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
this._map.on("zoomanim", this._unspiderfyZoomAnim, this);
|
|
1083
1915
|
},
|
|
1084
|
-
_unspiderfyZoomAnim: function(
|
|
1085
|
-
this._map._mapPane.classList.contains("leaflet-touching")
|
|
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);
|
|
1086
1922
|
},
|
|
1087
1923
|
_unspiderfyWrapper: function() {
|
|
1088
1924
|
this._unspiderfy();
|
|
1089
1925
|
},
|
|
1090
|
-
_unspiderfy: function(
|
|
1091
|
-
|
|
1926
|
+
_unspiderfy: function(zoomDetails) {
|
|
1927
|
+
if (this._spiderfied) {
|
|
1928
|
+
this._spiderfied.unspiderfy(zoomDetails);
|
|
1929
|
+
}
|
|
1092
1930
|
},
|
|
1093
1931
|
_noanimationUnspiderfy: function() {
|
|
1094
|
-
|
|
1932
|
+
if (this._spiderfied) {
|
|
1933
|
+
this._spiderfied._noanimationUnspiderfy();
|
|
1934
|
+
}
|
|
1095
1935
|
},
|
|
1096
1936
|
//If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc
|
|
1097
|
-
_unspiderfyLayer: function(
|
|
1098
|
-
|
|
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
|
+
}
|
|
1099
1949
|
}
|
|
1100
1950
|
});
|
|
1101
|
-
|
|
1951
|
+
L.MarkerClusterGroup.include({
|
|
1102
1952
|
/**
|
|
1103
1953
|
* Updates the icon of all clusters which are parents of the given marker(s).
|
|
1104
1954
|
* In singleMarkerMode, also updates the given marker(s) icon.
|
|
@@ -1107,19 +1957,39 @@ u.MarkerClusterGroup.include({
|
|
|
1107
1957
|
* clusters need to be updated. If not provided, retrieves all child markers of this.
|
|
1108
1958
|
* @returns {L.MarkerClusterGroup}
|
|
1109
1959
|
*/
|
|
1110
|
-
refreshClusters: function(
|
|
1111
|
-
|
|
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;
|
|
1112
1978
|
},
|
|
1113
1979
|
/**
|
|
1114
1980
|
* Simply flags all parent clusters of the given markers as having a "dirty" icon.
|
|
1115
1981
|
* @param layers Array(L.Marker)|Map(L.Marker) list of markers.
|
|
1116
1982
|
* @private
|
|
1117
1983
|
*/
|
|
1118
|
-
_flagParentsIconsNeedUpdate: (
|
|
1119
|
-
var
|
|
1120
|
-
for (
|
|
1121
|
-
|
|
1122
|
-
|
|
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
|
+
}
|
|
1123
1993
|
},
|
|
1124
1994
|
/**
|
|
1125
1995
|
* Re-draws the icon of the supplied markers.
|
|
@@ -1127,13 +1997,17 @@ u.MarkerClusterGroup.include({
|
|
|
1127
1997
|
* @param layers Array(L.Marker)|Map(L.Marker) list of markers.
|
|
1128
1998
|
* @private
|
|
1129
1999
|
*/
|
|
1130
|
-
_refreshSingleMarkerModeMarkers: function(
|
|
1131
|
-
var
|
|
1132
|
-
for (
|
|
1133
|
-
|
|
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
|
+
}
|
|
1134
2008
|
}
|
|
1135
2009
|
});
|
|
1136
|
-
|
|
2010
|
+
L.Marker.include({
|
|
1137
2011
|
/**
|
|
1138
2012
|
* Updates the given options in the marker's icon and refreshes the marker.
|
|
1139
2013
|
* @param options map object of icon options.
|
|
@@ -1141,9 +2015,14 @@ u.Marker.include({
|
|
|
1141
2015
|
* MCG.refreshClustersOf() right away with this single marker.
|
|
1142
2016
|
* @returns {L.Marker}
|
|
1143
2017
|
*/
|
|
1144
|
-
refreshIconOptions: function(
|
|
1145
|
-
var
|
|
1146
|
-
|
|
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;
|
|
1147
2026
|
}
|
|
1148
2027
|
});
|
|
1149
2028
|
//# sourceMappingURL=cluster.js.map
|