[Pkg-javascript-commits] [leaflet-markercluster] 170/479: Respect disableClusteringAtZoom when adding individual layers
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:26 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit 9a6e7004b0d07f7b13fe90c39305cb9354784255
Author: danzel <danzel at localhost.geek.nz>
Date: Mon Aug 20 10:18:34 2012 +1200
Respect disableClusteringAtZoom when adding individual layers
---
src/MarkerCluster.js | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index f900e72..3d7500b 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -107,8 +107,9 @@ L.MarkerCluster = L.Marker.extend({
// false: wasn't able to put this marker in
// a MarkerCluster: the visible parent of the marker
_recursivelyAddLayer: function (layer, zoom) {
- var map = this._group._map,
- maxClusterRadius = this._group.options.maxClusterRadius,
+ var group = this._group,
+ map = group._map,
+ maxClusterRadius = group.options.maxClusterRadius,
result = false,
i;
@@ -127,21 +128,24 @@ L.MarkerCluster = L.Marker.extend({
//Couldn't add it to a child, but it should be part of us (this._zoom -> we are the root node)
if (!result && (this._canAcceptPosition(layer.getLatLng(), zoom) || ('_zoom' in this))) {
- //Add to ourself instead
- var layerPos = map.project(layer.getLatLng(), zoom + 1),
- sqDist = this._group._sqDist;
-
- //var distanceGrid = new L.DistanceGrid(maxClusterRadius);
- for (i = this._markers.length - 1; i >= 0; i--) {
- var m = this._markers[i];
- if (sqDist(layerPos, map.project(m.getLatLng(), zoom + 1)) < (maxClusterRadius * maxClusterRadius)) {
- result = m;
- this._markers.splice(i, 1);
- this._childCount--;
- break;
+ //If we are allowed to cluster at our childs level
+ if (zoom + 1 !== group.options.disableClusteringAtZoom) {
+
+ //Add to ourself instead
+ var layerPos = map.project(layer.getLatLng(), zoom + 1),
+ sqDist = this._group._sqDist;
+
+ //var distanceGrid = new L.DistanceGrid(maxClusterRadius);
+ for (i = this._markers.length - 1; i >= 0; i--) {
+ var m = this._markers[i];
+ if (sqDist(layerPos, map.project(m.getLatLng(), zoom + 1)) < (maxClusterRadius * maxClusterRadius)) {
+ result = m;
+ this._markers.splice(i, 1);
+ this._childCount--;
+ break;
+ }
}
}
-
//result = distanceGrid.getNearObject(map.project(layer.getLatLng(), zoom + 1));
if (result) {
@@ -158,6 +162,11 @@ L.MarkerCluster = L.Marker.extend({
maxZoom = map.getMaxZoom(),
newResult,
finalResult = (zoom === wantedZoom) ? result : true;
+
+ if (group.options.disableClusteringAtZoom) {
+ maxZoom = group.options.disableClusteringAtZoom - 2;
+ }
+
while (zoom < maxZoom) {
zoom++;
--
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