[Pkg-javascript-commits] [leaflet-markercluster] 108/219: Corrected compatibility with MCG and added direct refresh of MCG when refreshing Marker
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit a12254c67c884d6604febe42b097570c443fe7f7
Author: ghybs <ghybs1 at gmail.com>
Date: Fri Oct 2 01:53:20 2015 +0400
Corrected compatibility with MCG and added direct refresh of MCG when refreshing Marker
---
src/MarkerClusterGroup.Refresh.js | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/src/MarkerClusterGroup.Refresh.js b/src/MarkerClusterGroup.Refresh.js
index dc6b83e..382affa 100644
--- a/src/MarkerClusterGroup.Refresh.js
+++ b/src/MarkerClusterGroup.Refresh.js
@@ -3,21 +3,24 @@
* markers' icon options and refreshing their icon and their parent clusters
* accordingly (case where their iconCreateFunction uses data of childMarkers
* to make up the cluster icon).
- * Should cover issues #561, #555, #535 and #498.
+ * Should cover issues #563, #561, #555, #535 and #498.
*/
L.MarkerClusterGroup.include({
/**
* Updates all clusters (and their icon) which are parents of the given marker(s).
- * @param layers L.MarkerClusterGroup|L.LayerGroup|Array(L.Marker)|L.Marker
- * list of markers (or single marker) whose parent clusters need update.
+ * @param layers L.MarkerClusterGroup|L.LayerGroup|Array(L.Marker)|Map(L.Marker)|
+ * L.MarkerCluster|L.Marker list of markers (or single marker) whose parent
+ * clusters need to be updated.
*/
refreshClustersOf: function (layers) {
if (layers instanceof L.MarkerClusterGroup) {
- layers = layers.getAllChildMarkers();
+ layers = layers._topClusterLevel.getAllChildMarkers();
} else if (layers instanceof L.LayerGroup) {
layers = layers._layers;
+ } else if (layers instanceof L.MarkerCluster) {
+ layers = layers.getAllChildMarkers();
} else if (layers instanceof L.Marker) {
layers = [layers];
}
@@ -66,12 +69,24 @@ L.Marker.include({
/**
* Updates the given options in the marker's icon and refreshes the marker.
* @param options map object of icon options.
+ * @param directlyRefreshClusters boolean true to trigger MCG.refreshClustersOf()
+ * right away with this single marker.
*/
- refreshIconWithOptions: function (options) {
+ refreshIconWithOptions: function (options, directlyRefreshClusters) {
var icon = this.options.icon;
L.setOptions(icon, options);
this.setIcon(icon);
+
+ // Shortcut to refresh the associated MCG clusters right away.
+ // To be used when refreshing a single marker.
+ // Otherwise, better use MCG.refreshClustersOf() once at the end with
+ // the list of modified markers.
+ if (directlyRefreshClusters && this.__parent) {
+ this.__parent._group.refreshClustersOf(this);
+ }
+
+ return this;
}
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git
More information about the Pkg-javascript-commits
mailing list