[Pkg-javascript-commits] [leaflet-markercluster] 27/31: Default group clusterPane to L.Marker default

Jonas Smedegaard dr at jones.dk
Sun Oct 22 17:29:31 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag upstream/1.1.0_dfsg
in repository leaflet-markercluster.

commit 37bc740041bdd6a537a1e8cfffb18fc18f2b0724
Author: ckrahe <chris at krahe.org>
Date:   Wed Aug 23 12:05:06 2017 -0400

    Default group clusterPane to L.Marker default
---
 README.md                 | 2 +-
 spec/suites/PaneSpec.js   | 4 ++--
 src/MarkerCluster.js      | 9 ++-------
 src/MarkerClusterGroup.js | 3 +++
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index f79edc2..0cd0a9b 100644
--- a/README.md
+++ b/README.md
@@ -130,7 +130,7 @@ If you need to update the clusters icon (e.g. they are based on markers real-tim
 * **spiderLegPolylineOptions**: Allows you to specify [PolylineOptions](http://leafletjs.com/reference.html#polyline-options) to style spider legs. By default, they are `{ weight: 1.5, color: '#222', opacity: 0.5 }`.
 * **spiderfyDistanceMultiplier**: Increase from 1 to increase the distance away from the center that spiderfied markers are placed. Use if you are using big marker icons (Default: 1).
 * **iconCreateFunction**: Function used to create the cluster icon. See [the default implementation](https://github.com/Leaflet/Leaflet.markercluster/blob/15ed12654acdc54a4521789c498e4603fe4bf781/src/MarkerClusterGroup.js#L542) or the [custom example](https://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-custom.html).
-* **clusterPane**: Map pane where the cluster icons will be added. Defaults to markerPane. [See the pane example](https://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-pane.html).
+* **clusterPane**: Map pane where the cluster icons will be added. Defaults to L.Marker's default (currently 'markerPane'). [See the pane example](https://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-pane.html).
 
 #### Chunked addLayers options
 Options for the [addLayers](#bulk-adding-and-removing-markers) method. See [#357](https://github.com/Leaflet/Leaflet.markercluster/issues/357) for explanation on how the chunking works.
diff --git a/spec/suites/PaneSpec.js b/spec/suites/PaneSpec.js
index c78fd0b..f3728a1 100644
--- a/spec/suites/PaneSpec.js
+++ b/spec/suites/PaneSpec.js
@@ -75,7 +75,7 @@ describe('Map pane selection', function() {
         expect(map._panes.testPane.childNodes.length).to.be(1);
     });
 
-    it('defaults to markerPane', function() {
+    it('defaults to default marker pane', function() {
         group = new L.MarkerClusterGroup();
 
         var marker = new L.Marker([1.5, 1.5]);
@@ -84,7 +84,7 @@ describe('Map pane selection', function() {
         group.addLayers([marker, marker2]);
         map.addLayer(group);
 
-        expect(map._panes.markerPane.childNodes.length).to.be(1);
+        expect(map._panes[L.Marker.prototype.options.pane].childNodes.length).to.be(1);
     });
 
     /////////////////////////////
diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index b8db369..f8b546f 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -1,13 +1,8 @@
 L.MarkerCluster = L.Marker.extend({
 	initialize: function (group, zoom, a, b) {
 
-		var options = { icon: this };
-		if (group.options.clusterPane) {
-		    options.pane = group.options.clusterPane;
-        }
-
-		L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), options);
-
+		L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0),
+            { icon: this, pane: group.options.clusterPane });
 
 		this._group = group;
 		this._zoom = zoom;
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index c741fb6..0c384fd 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -49,6 +49,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		if (!this.options.iconCreateFunction) {
 			this.options.iconCreateFunction = this._defaultIconCreateFunction;
 		}
+		if (!this.options.clusterPane) {
+		    this.options.clusterPane = L.Marker.prototype.options.pane;
+        }
 
 		this._featureGroup = L.featureGroup();
 		this._featureGroup.addEventParent(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