Remove interactions from MapProperty

This commit is contained in:
Frederic Junod
2012-10-03 11:39:04 +02:00
parent 10708ccfea
commit 488a8224c3
+19 -23
View File
@@ -101,7 +101,6 @@ ol.MapEventType = {
ol.MapProperty = { ol.MapProperty = {
BACKGROUND_COLOR: 'backgroundColor', BACKGROUND_COLOR: 'backgroundColor',
CENTER: 'center', CENTER: 'center',
INTERACTIONS: 'interactions',
LAYERS: 'layers', LAYERS: 'layers',
PROJECTION: 'projection', PROJECTION: 'projection',
RESOLUTION: 'resolution', RESOLUTION: 'resolution',
@@ -237,6 +236,12 @@ ol.Map = function(mapOptions) {
goog.events.listen(this.controls_, ol.CollectionEventType.REMOVE, goog.events.listen(this.controls_, ol.CollectionEventType.REMOVE,
this.handleControlsRemove_, false, this); this.handleControlsRemove_, false, this);
/**
* @type {ol.Collection}
* @private
*/
this.interactions_ = mapOptionsInternal.interactions;
/** /**
* @type {ol.renderer.Map} * @type {ol.renderer.Map}
* @private * @private
@@ -390,12 +395,8 @@ ol.Map.prototype.getExtent = function() {
* @return {ol.Collection} Interactions. * @return {ol.Collection} Interactions.
*/ */
ol.Map.prototype.getInteractions = function() { 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); 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. * @param {ol.Collection} layers Layers.
*/ */
@@ -953,6 +942,7 @@ ol.Map.prototype.zoomToResolution = function(resolution, opt_anchor) {
/** /**
* @typedef {{controls: ol.Collection, * @typedef {{controls: ol.Collection,
* interactions: ol.Collection,
* constraints: ol.Constraints, * constraints: ol.Constraints,
* rendererConstructor: * rendererConstructor:
* function(new: ol.renderer.Map, Element, ol.Map), * 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.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) ? values[ol.MapProperty.LAYERS] = goog.isDef(mapOptions.layers) ?
mapOptions.layers : new ol.Collection(); mapOptions.layers : new ol.Collection();
@@ -1046,6 +1031,16 @@ ol.Map.createOptionsInternal = function(mapOptions) {
controls = ol.Map.createControls_(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} * @type {Element}
*/ */
@@ -1054,6 +1049,7 @@ ol.Map.createOptionsInternal = function(mapOptions) {
return { return {
constraints: constraints, constraints: constraints,
controls: controls, controls: controls,
interactions: interactions,
rendererConstructor: rendererConstructor, rendererConstructor: rendererConstructor,
target: target, target: target,
values: values values: values