diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js index 627933dac..c41c5af30 100644 --- a/src/MarkerCluster.js +++ b/src/MarkerCluster.js @@ -161,9 +161,9 @@ L.MarkerCluster = L.Marker.extend({ nm._backupLatlng = nm.getLatLng(); nm.setLatLng(startPos); + nm.setOpacity(0); } - L.FeatureGroup.prototype.addLayer.call(this._group, nm); } diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 91fd1d410..14d8e0062 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -444,6 +444,16 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { } } + //Immediately fire an event to update the opacity (If we immediately set it they won't animate) + setTimeout(function () { + for (i in me._layers) { + var n = me._layers[i]; + + if (!(n instanceof L.MarkerCluster) && n._icon) { + n.setOpacity(1); + } + } + }, 0); this._inZoomAnimation++; //Start up a function to update the positions of the just added clusters/markers @@ -480,7 +490,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { var me = this; - //TODO: Maybe use the transition timing stuff to make this more reliable + //Immediately fire an event to update the opacity (If we immediately set it they won't animate) setTimeout(function () { for (i = 0; i < newClusters.length; i++) { var n = newClusters[i]; @@ -490,6 +500,8 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { } } }, 0); + + //TODO: Maybe use the transition timing stuff to make this more reliable setTimeout(function () { map._mapPane.className = map._mapPane.className.replace(' leaflet-cluster-anim', '');