[Pkg-javascript-commits] [leaflet-markercluster] 383/479: Support adding random things to the MarkerClusterGroup. Don't try to to cluster them. Refs #195
Jonas Smedegaard
dr at jones.dk
Thu Oct 16 16:00:59 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 cbe92f146801c0d7183528d97635877925d6898e
Author: danzel <danzel at localhost.geek.nz>
Date: Fri Jun 21 16:41:56 2013 +1200
Support adding random things to the MarkerClusterGroup. Don't try to to cluster them. Refs #195
---
src/MarkerClusterGroup.js | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 47429d0..1f820a1 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -95,6 +95,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
removeLayer: function (layer) {
+ //If the layer doesn't have a getLatLng then we can't cluster it, so add it to our child featureGroup
+ if (!layer.getLatLng) {
+ this._featureGroup.removeLayer(layer);
+ return this;
+ }
+
if (!this._map) {
if (!this._arraySplice(this._needsClustering, layer) && this.hasLayer(layer)) {
this._needsRemoving.push(layer);
@@ -128,6 +134,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
addLayers: function (layersArray) {
var i, l, m,
fg = this._featureGroup;
+
if (!this._map) {
this._needsClustering = this._needsClustering.concat(layersArray);
return this;
@@ -136,6 +143,12 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
for (i = 0, l = layersArray.length; i < l; i++) {
m = layersArray[i];
+ //Not point data, can't be clustered
+ if (!m.getLatLng) {
+ fg.addLayer(m);
+ continue;
+ }
+
if (this.hasLayer(m)) {
continue;
}
@@ -344,6 +357,14 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
for (i = 0, l = this._needsClustering.length; i < l; i++) {
layer = this._needsClustering[i];
+
+ //If the layer doesn't have a getLatLng then we can't cluster it, so add it to our child featureGroup
+ if (!layer.getLatLng) {
+ this._featureGroup.addLayer(layer);
+ continue;
+ }
+
+
if (layer.__parent) {
continue;
}
--
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