diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index c30d4bab3..2f089396b 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -52,10 +52,6 @@ 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 3ed33d3f6..2bd0770a9 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -43,6 +43,17 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ return this; } + if (this.options.singleMarkerMode) { + layer.options.icon = this.options.iconCreateFunction({ + getChildCount: function () { + return 1; + }, + getAllChildMarkers: function () { + return [layer]; + } + }); + } + if (!this._map) { this._needsClustering.push(layer); return this;