Fix and test for #49, clearLayers wasn't unspiderfying.

This commit is contained in:
danzel
2012-09-07 14:10:05 +12:00
parent 7ae3e1ad42
commit fb165b18b1
2 changed files with 10 additions and 1 deletions
+6 -1
View File
@@ -21,9 +21,11 @@
<body>
<div id="map"></div>
<button id="doit">Remove and add direct to map</button><br/>
<button id="doit">Remove and add direct to map</button><button id="doit2">clearLayers</button><br/>
<span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/54">#54</a>. Spiderfy the cluster then click the button. Should result in 2 markers right beside each other on the map.</span><br/>
<span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/53">#53</a>. Spiderfy the cluster then click the button. Spider lines remain on the map.</span>
<span>Bug <a href="https://github.com/danzel/Leaflet.markercluster/issues/49">#49</a>. Spiderfy the cluster then click the second button. Spider lines remain on the map. Click the map to get an error.</span>
<script type="text/javascript">
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
@@ -52,6 +54,9 @@
map.addLayer(markersList[0]);
map.addLayer(markersList[1]);
};
L.DomUtil.get('doit2').onclick = function () {
markers.clearLayers();
};
</script>
</body>
+4
View File
@@ -103,6 +103,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
clearLayers: function () {
//Need our own special implementation as the LayerGroup one doesn't work for us
if (this._unspiderfy) {
this._unspiderfy();
}
//If we aren't on the map yet, just blow away the markers we know of
if (!this._map) {
this._needsClustering = [];