From 7df3c7506fccc8f70708ce2ae8c28916bac00f12 Mon Sep 17 00:00:00 2001 From: Paul Spencer Date: Fri, 1 Nov 2013 08:03:06 -0400 Subject: [PATCH] Add support for passing interactions as an array for consistency. --- src/objectliterals.jsdoc | 5 ++--- src/ol/map.js | 13 +++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 20ad3b0d15..78a0e7cbeb 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -57,9 +57,8 @@ * @typedef {Object} ol.MapOptions * @property {ol.Collection|Array.|undefined} controls * Controls initially added to the map. - * @property {ol.Collection|undefined} interactions A collection of - * {@link ol.interaction|ol.interaction.Interaction} instances that allow the user to interact with - * the map. + * @property {ol.Collection|Array.|undefined} + * interactions Interactions that are initially added to the map. * @property {Array.|ol.Collection|undefined} layers Layers. * @property {ol.Collection|Array.|undefined} overlays * Overlays initially added to the map. diff --git a/src/ol/map.js b/src/ol/map.js index 21776f8af5..624da19af3 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1274,8 +1274,17 @@ ol.Map.createOptionsInternal = function(options) { controls = ol.control.defaults(); } - var interactions = goog.isDef(options.interactions) ? - options.interactions : ol.interaction.defaults(); + var interactions; + if (goog.isDef(options.interactions)) { + if (goog.isArray(options.interactions)) { + interactions = new ol.Collection(goog.array.clone(options.interactions)); + } else { + goog.asserts.assertInstanceof(options.interactions, ol.Collection); + interactions = options.interactions; + } + } else { + interactions = ol.interaction.defaults(); + } var overlays; if (goog.isDef(options.overlays)) {