Remove interactions from MapProperty

This commit is contained in:
Frederic Junod
2012-10-03 11:39:04 +02:00
parent 10708ccfea
commit 488a8224c3

View File

@@ -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