From ab3cdd49a1d0b23eef97f2087656210886aa5552 Mon Sep 17 00:00:00 2001 From: "Ryan \"rman\" Denniston" Date: Fri, 31 Oct 2014 23:28:32 -1000 Subject: [PATCH 1/5] made a minor change to _zoomOrSpiderfy to Spiderfy without zooming if everything in the cluster is at the same lat long. This prevents zooming into max level if there is no real reason to do so, since all points will be at the same location. This minor change increased usability in a personal project. --- src/MarkerClusterGroup.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 03e42750da..58794c3a35 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -655,7 +655,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ _zoomOrSpiderfy: function (e) { var map = this._map; - if (map.getMaxZoom() === map.getZoom()) { + if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)){ + if (this.options.spiderfyOnMaxZoom) { + e.layer.spiderfy(); + } + }else if (map.getMaxZoom() === map.getZoom()) { if (this.options.spiderfyOnMaxZoom) { e.layer.spiderfy(); } From 50f0a553b9a37017f3bfcaedf7fcc6ceb6d58dd2 Mon Sep 17 00:00:00 2001 From: "Ryan \"rman\" Denniston" Date: Sat, 1 Nov 2014 11:23:15 -1000 Subject: [PATCH 2/5] fixed whitespace issues --- src/MarkerClusterGroup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 58794c3a35..04d7f1c49a 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -655,11 +655,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ _zoomOrSpiderfy: function (e) { var map = this._map; - if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)){ + if ( e.layer._bounds._northEast.equals(e.layer._bounds._southWest)) { if (this.options.spiderfyOnMaxZoom) { e.layer.spiderfy(); } - }else if (map.getMaxZoom() === map.getZoom()) { + } else if (map.getMaxZoom() === map.getZoom()) { if (this.options.spiderfyOnMaxZoom) { e.layer.spiderfy(); } From f79a3d0ba9d4b003771bce579f67b3e9156f630a Mon Sep 17 00:00:00 2001 From: "Ryan \"rman\" Denniston" Date: Sat, 1 Nov 2014 11:25:26 -1000 Subject: [PATCH 3/5] fixed a newly created whitespace issue --- src/MarkerClusterGroup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 04d7f1c49a..d6b408fe52 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -655,7 +655,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ _zoomOrSpiderfy: function (e) { var map = this._map; - if ( e.layer._bounds._northEast.equals(e.layer._bounds._southWest)) { + if (e.layer._bounds._northEast.equals(e.layer._bounds._southWest)) { if (this.options.spiderfyOnMaxZoom) { e.layer.spiderfy(); } From bdb00de90c562874c4345cd3ec63b48881377e34 Mon Sep 17 00:00:00 2001 From: "Ryan \"rman\" Denniston" Date: Sat, 1 Nov 2014 11:51:16 -1000 Subject: [PATCH 4/5] updated readme to reflect new difference in behavior for spiderfyOnMaxZoom option --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f762995d3f..95fb082978 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ map.addLayer(markers); By default the Clusterer enables some nice defaults for you: * **showCoverageOnHover**: When you mouse over a cluster it shows the bounds of its markers. * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds. -* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. +* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note:* the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.) * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance. You can disable any of these as you want in the options when you create the MarkerClusterGroup: @@ -58,7 +58,7 @@ Check out the [custom example](http://leaflet.github.com/Leaflet.markercluster/e Enabled by default (boolean options): * **showCoverageOnHover**: When you mouse over a cluster it shows the bounds of its markers. * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds. -* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. +* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note:* the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.) * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance. Other options From 229eb9c6719f71b3d40a076126c2b4ca16f1c6c8 Mon Sep 17 00:00:00 2001 From: "Ryan \"rman\" Denniston" Date: Sat, 1 Nov 2014 11:54:20 -1000 Subject: [PATCH 5/5] changed a small formatting issue to include italic in the entire note --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 95fb082978..cfc1919399 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ map.addLayer(markers); By default the Clusterer enables some nice defaults for you: * **showCoverageOnHover**: When you mouse over a cluster it shows the bounds of its markers. * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds. -* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note:* the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.) +* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note: the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.*) * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance. You can disable any of these as you want in the options when you create the MarkerClusterGroup: @@ -58,7 +58,7 @@ Check out the [custom example](http://leaflet.github.com/Leaflet.markercluster/e Enabled by default (boolean options): * **showCoverageOnHover**: When you mouse over a cluster it shows the bounds of its markers. * **zoomToBoundsOnClick**: When you click a cluster we zoom to its bounds. -* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note:* the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.) +* **spiderfyOnMaxZoom**: When you click a cluster at the bottom zoom level we spiderfy it so you can see all of its markers. (*Note: the spiderfy occurs at the current zoom level if all items within the cluster are physically located at the same latitude and longitude.*) * **removeOutsideVisibleBounds**: Clusters and markers too far from the viewport are removed from the map for performance. Other options