From 488a8224c366adfb7ea84a092e965331cb551cfd Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 3 Oct 2012 11:39:04 +0200 Subject: [PATCH] Remove interactions from MapProperty --- src/ol/map.js | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index f15a0f3e22..33ee8bc1e6 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -101,7 +101,6 @@ ol.MapEventType = { ol.MapProperty = { BACKGROUND_COLOR: 'backgroundColor', CENTER: 'center', - INTERACTIONS: 'interactions', LAYERS: 'layers', PROJECTION: 'projection', RESOLUTION: 'resolution', @@ -237,6 +236,12 @@ ol.Map = function(mapOptions) { goog.events.listen(this.controls_, ol.CollectionEventType.REMOVE, this.handleControlsRemove_, false, this); + /** + * @type {ol.Collection} + * @private + */ + this.interactions_ = mapOptionsInternal.interactions; + /** * @type {ol.renderer.Map} * @private @@ -390,12 +395,8 @@ ol.Map.prototype.getExtent = function() { * @return {ol.Collection} Interactions. */ ol.Map.prototype.getInteractions = function() { - return /** @type {ol.Collection} */ this.get(ol.MapProperty.INTERACTIONS); + return this.interactions_; }; -goog.exportProperty( - ol.Map.prototype, - 'getInteractions', - ol.Map.prototype.getInteractions); /** @@ -757,18 +758,6 @@ goog.exportProperty( ol.Map.prototype.setCenter); -/** - * @param {ol.Collection} interactions Interactions. - */ -ol.Map.prototype.setInteractions = function(interactions) { - this.set(ol.MapProperty.INTERACTIONS, interactions); -}; -goog.exportProperty( - ol.Map.prototype, - 'setInteractions', - ol.Map.prototype.setInteractions); - - /** * @param {ol.Collection} layers Layers. */ @@ -953,6 +942,7 @@ ol.Map.prototype.zoomToResolution = function(resolution, opt_anchor) { /** * @typedef {{controls: ol.Collection, + * interactions: ol.Collection, * constraints: ol.Constraints, * rendererConstructor: * function(new: ol.renderer.Map, Element, ol.Map), @@ -977,11 +967,6 @@ ol.Map.createOptionsInternal = function(mapOptions) { values[ol.MapProperty.CENTER] = mapOptions.center; } - values[ol.MapProperty.INTERACTIONS] = - goog.isDef(mapOptions.interactions) ? - mapOptions.interactions : - ol.Map.createInteractions_(mapOptions); - values[ol.MapProperty.LAYERS] = goog.isDef(mapOptions.layers) ? mapOptions.layers : new ol.Collection(); @@ -1046,6 +1031,16 @@ ol.Map.createOptionsInternal = function(mapOptions) { controls = ol.Map.createControls_(mapOptions); } + /** + * @type {ol.Collection} + */ + var interactions; + if (goog.isDef(mapOptions.interactions)) { + interactions = mapOptions.interactions; + } else { + interactions = ol.Map.createInteractions_(mapOptions); + } + /** * @type {Element} */ @@ -1054,6 +1049,7 @@ ol.Map.createOptionsInternal = function(mapOptions) { return { constraints: constraints, controls: controls, + interactions: interactions, rendererConstructor: rendererConstructor, target: target, values: values