From 068f9f9f8a08424ddb0816cb0b3afb70f6c9d690 Mon Sep 17 00:00:00 2001 From: Alec Winograd Date: Fri, 31 Aug 2012 23:06:39 -0700 Subject: [PATCH] Add option singleMarkerMode Defaults to false. Setting to true causes markers to appear as clusters with count 1. This is done by overriding the Marker's icon to the Group's iconCreateFunction. --- .../marker-clustering-singlemarkermode.html | 61 +++++++++++++++++++ src/MarkerCluster.js | 4 ++ src/MarkerClusterGroup.js | 1 + 3 files changed, 66 insertions(+) create mode 100644 example/marker-clustering-singlemarkermode.html diff --git a/example/marker-clustering-singlemarkermode.html b/example/marker-clustering-singlemarkermode.html new file mode 100644 index 000000000..60eef82e7 --- /dev/null +++ b/example/marker-clustering-singlemarkermode.html @@ -0,0 +1,61 @@ + + + + Leaflet debug page + + + + + + + + + + + + + + +
+ Click a cluster to zoom to its bounds + + + + diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index b0fa84a34..ffd782809 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -52,6 +52,10 @@ L.MarkerCluster = L.Marker.extend({ this._childClusters.push(new1); this._childCount += new1._childCount; } else { + if (this._group.options.singleMarkerMode === true) { + new1.options.icon = this._group.options.iconCreateFunction(1); + } + this._markers.push(new1); this._childCount++; } diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index f685d8d82..1ae6542fe 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -12,6 +12,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ spiderfyOnMaxZoom: true, showCoverageOnHover: true, zoomToBoundsOnClick: true, + singleMarkerMode: false, disableClusteringAtZoom: null },