Skip to content

Commit

Permalink
Merge pull request #287 from gberaudo/fix_group_synchronization
Browse files Browse the repository at this point in the history
Fix group removal
  • Loading branch information
gberaudo committed Nov 16, 2015
2 parents e756630 + fddb4f4 commit c68901a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/abstractsynchronizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ olcs.AbstractSynchronizer.prototype.addLayers_ = function(root) {
/**
* Remove and destroy a single layer.
* @param {ol.layer.Layer} layer
* @return {boolean} counterpart destroyed
* @private
*/
olcs.AbstractSynchronizer.prototype.removeAndDestroySingleLayer_ =
Expand All @@ -147,6 +148,7 @@ olcs.AbstractSynchronizer.prototype.removeAndDestroySingleLayer_ =
delete this.olLayerListenKeys_[uid];
}
delete this.layerMap[uid];
return !!counterparts;
};


Expand Down Expand Up @@ -180,13 +182,14 @@ olcs.AbstractSynchronizer.prototype.removeLayer_ = function(root) {
var fifo = [root];
while (fifo.length > 0) {
var olLayer = fifo.splice(0, 1)[0];
var done = this.removeAndDestroySingleLayer_(olLayer);
if (olLayer instanceof ol.layer.Group) {
this.unlistenSingleGroup_(olLayer);
olLayer.getLayers().forEach(function(l) {
fifo.push(l);
});
} else {
this.removeAndDestroySingleLayer_(olLayer);
if (done) {
olLayer.getLayers().forEach(function(l) {
fifo.push(l);
});
}
}
}
}
Expand Down

0 comments on commit c68901a

Please sign in to comment.