[Pkg-javascript-commits] [leaflet-markercluster] 13/31: Fix non-integer min/max zoom and add a test. Ref #789
Jonas Smedegaard
dr at jones.dk
Sun Oct 22 17:29:29 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 e387e1f48f7ce7b006588e3565072c071803e80e
Author: danzel <danzel at localhost.geek.nz>
Date: Sat Jun 10 16:53:06 2017 +1200
Fix non-integer min/max zoom and add a test. Ref #789
---
spec/index.html | 1 +
spec/suites/nonIntegerZoomSpec.js | 40 +++++++++++++++++++++++++++++++++++++++
src/MarkerClusterGroup.js | 4 ++--
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/spec/index.html b/spec/index.html
index fcf995d..694bad9 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -70,6 +70,7 @@
<script type="text/javascript" src="suites/RefreshSpec.js"></script>
<script type="text/javascript" src="suites/removeOutsideVisibleBoundsSpec.js"></script>
+ <script type="text/javascript" src="suites/nonIntegerZoomSpec.js"></script>
<script>
(window.mochaPhantomJS || window.mocha).run();
diff --git a/spec/suites/nonIntegerZoomSpec.js b/spec/suites/nonIntegerZoomSpec.js
new file mode 100644
index 0000000..4c6d94e
--- /dev/null
+++ b/spec/suites/nonIntegerZoomSpec.js
@@ -0,0 +1,40 @@
+describe('non-integer min/max zoom', function () {
+ var map, div, clock;
+ beforeEach(function () {
+ clock = sinon.useFakeTimers();
+
+ div = document.createElement('div');
+ div.style.width = '200px';
+ div.style.height = '200px';
+ document.body.appendChild(div);
+
+ map = L.map(div, { minZoom: 0.5, maxZoom: 18.5 });
+
+ map.fitBounds(new L.LatLngBounds([
+ [1, 1],
+ [2, 2]
+ ]));
+ });
+ afterEach(function () {
+ clock.restore();
+ document.body.removeChild(div);
+ });
+
+ it('dont break adding and removing markers', function () {
+
+ var group = new L.MarkerClusterGroup();
+ var marker = new L.Marker([1.5, 1.5]);
+ var marker2 = new L.Marker([1.5, 1.5]);
+
+ group.addLayer(marker);
+ group.addLayer(marker2);
+ map.addLayer(group);
+
+ expect(marker._icon).to.be(undefined);
+ expect(marker2._icon).to.be(undefined);
+
+ expect(map._panes.markerPane.childNodes.length).to.be(1);
+
+ group.removeLayer(marker2);
+ });
+});
\ No newline at end of file
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index bca2d2a..3da2360 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -921,8 +921,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
},
_generateInitialClusters: function () {
- var maxZoom = this._map.getMaxZoom(),
- minZoom = this._map.getMinZoom(),
+ var maxZoom = Math.ceil(this._map.getMaxZoom()),
+ minZoom = Math.floor(this._map.getMinZoom()),
radius = this.options.maxClusterRadius,
radiusFn = radius;
--
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