Allow layers to be passed as an array when creating a map
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@exportObjectLiteral ol.MapOptions
|
||||
@exportObjectLiteralProperty ol.MapOptions.controls Array.<ol.control.Control>|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.interactions ol.Collection|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.layers ol.Collection|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.layers Array.<ol.layer.Layer>|ol.Collection|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.renderers Array.<ol.RendererHint>|undefined
|
||||
@exportObjectLiteralProperty ol.MapOptions.target Element|string
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user