Use goog.dom functions and clean up when layers change

This commit is contained in:
Tom Payne
2012-08-02 17:02:14 +02:00
parent a96982f112
commit 62a6faa4d5
+7 -2
View File
@@ -119,7 +119,7 @@ ol.view.Attribution.prototype.createAttributionElementsForLayer_ =
goog.style.showElement(attributionElement, false); goog.style.showElement(attributionElement, false);
} }
this.ulElement_.appendChild(attributionElement); goog.dom.appendChild(this.ulElement_, attributionElement);
this.attributionElements_[attributionKey] = attributionElement; this.attributionElements_[attributionKey] = attributionElement;
@@ -182,7 +182,7 @@ ol.view.Attribution.prototype.removeLayer = function(layer) {
var attributionKey = goog.getUid(attribution); var attributionKey = goog.getUid(attribution);
delete this.coverageAreass_[attributionKey]; delete this.coverageAreass_[attributionKey];
var attributionElement = this.attributionElements_[attributionKey]; var attributionElement = this.attributionElements_[attributionKey];
this.ulElement_.removeChild(attributionElement); goog.dom.removeNode(attributionElement);
delete this.attributionElements_[attributionKey]; delete this.attributionElements_[attributionKey];
}, this); }, this);
@@ -257,6 +257,11 @@ ol.view.Attribution.prototype.handleMapLayersChanged = function() {
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey); goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
this.layersListenerKeys_ = null; this.layersListenerKeys_ = null;
} }
goog.object.forEach(this.attributionElements_, function(attributionElement) {
goog.dom.removeNode(attributionElement);
}, this);
this.attributionElements_ = {};
this.coverageAreass_ = {};
var map = this.getMap(); var map = this.getMap();
var layers = map.getLayers(); var layers = map.getLayers();
if (goog.isDefAndNotNull(layers)) { if (goog.isDefAndNotNull(layers)) {