diff --git a/src/ol/Map.js b/src/ol/Map.js index e20a4497c6..303dd5a316 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -16,6 +16,9 @@ goog.require('goog.asserts'); /** * @export * @constructor + * + * @event addlayer Fires when a layer is added to the map. The event object + * contains a 'layer' property referencing the added layer. */ ol.Map = function() { @@ -381,9 +384,22 @@ ol.Map.prototype.setResolutions = function(resolutions) { * @param {Array} layers the layers set on the map */ ol.Map.prototype.setLayers = function(layers) { - this.layers_ = layers; + //TODO remove layers properly if there are layers already + this.layers_ = []; + this.addLayers(layers); }; +ol.Map.prototype.addLayers = function(layers) { + var layer; + for (var i=0, ii=layers.length; i|undefined} opt_controls */