From dfc21754c9e375d7a09112ea05e4a3ada37eae98 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 24 Jun 2012 22:14:48 +0200 Subject: [PATCH] Adding addLayers method and addlayer event. --- src/ol/Map.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 */