Allow layers to be passed as an array when creating a map

This commit is contained in:
Tom Payne
2013-03-06 13:04:56 +01:00
parent 388eac3838
commit 61982646ba
2 changed files with 13 additions and 3 deletions
+12 -2
View File
@@ -823,8 +823,18 @@ ol.Map.createOptionsInternal = function(mapOptions) {
*/
var values = {};
values[ol.MapProperty.LAYERS] = goog.isDef(mapOptions.layers) ?
mapOptions.layers : new ol.Collection();
var layers;
if (goog.isDef(mapOptions.layers)) {
if (goog.isArray(mapOptions.layers)) {
layers = new ol.Collection(goog.array.clone(mapOptions.layers));
} else {
goog.asserts.assert(mapOptions.layers instanceof ol.Collection);
layers = mapOptions.layers;
}
} else {
layers = new ol.Collection();
}
values[ol.MapProperty.LAYERS] = layers;
values[ol.MapProperty.VIEW] = goog.isDef(mapOptions.view) ?
mapOptions.view : new ol.View2D();