[Pkg-javascript-commits] [leaflet-markercluster] 130/479: Support starting with 0 markers.
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:20 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 be9ff91a5b0154d4da2b8abf21c843df4b8de7d6
Author: danzel <danzel at localhost.geek.nz>
Date: Mon Jul 30 11:07:13 2012 +1200
Support starting with 0 markers.
---
src/MarkerCluster.js | 8 +++++++-
src/MarkerClusterGroup.js | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index d4b5539..9876845 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -8,7 +8,9 @@ L.MarkerCluster = L.Marker.extend({
this._bounds = new L.LatLngBounds();
- this._addChild(a);
+ if (a) {
+ this._addChild(a);
+ }
if (b) {
this._addChild(b);
}
@@ -156,6 +158,10 @@ L.MarkerCluster = L.Marker.extend({
},
_canAcceptPosition: function (latlng, zoom) {
+ if (this._childCount == 0) {
+ return true;
+ }
+
var clusterRadiusSqrd = this._group.options.maxClusterRadius * this._group.options.maxClusterRadius,
pos = this._group._map.project(this._latlng, zoom),
otherpos = this._group._map.project(latlng, zoom);
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index ed2b26c..9b850d5 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -307,15 +307,15 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
return { 'clusters': clusters, 'unclustered': unclustered };
},
-
+
//Clusters the given markers (with _cluster) and returns the result as a MarkerCluster
_clusterToMarkerCluster: function (toCluster, zoom) {
var res = this._cluster(toCluster, zoom),
toAdd = res.clusters.concat(res.unclustered),
- result = new L.MarkerCluster(this, toAdd[0]),
+ result = new L.MarkerCluster(this),
i;
- for (i = toAdd.length - 1; i > 0; i--) {
+ for (i = toAdd.length - 1; i >= 0; i--) {
result._addChild(toAdd[i]);
}
result._zoom = 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