Give interactions a reference to the map

This is in line with what we do for controls and overlays.  A follow-up change will add calls to `setMap` when interactions are added to a map.
This commit is contained in:
Tim Schaub
2013-10-25 11:53:54 -06:00
parent d211f65203
commit 7d2d68c011
2 changed files with 77 additions and 0 deletions

View File

@@ -12,6 +12,22 @@ goog.require('ol.easing');
* @constructor
*/
ol.interaction.Interaction = function() {
/**
* @private
* @type {ol.Map}
*/
this.map_ = null;
};
/**
* Get the map associated with this interaction.
* @return {ol.Map} Map.
*/
ol.interaction.Interaction.prototype.getMap = function() {
return this.map_;
};
@@ -25,6 +41,17 @@ ol.interaction.Interaction.prototype.handleMapBrowserEvent =
goog.abstractMethod;
/**
* Remove the interaction from its current map and attach it to the new map.
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param {ol.Map} map Map.
*/
ol.interaction.Interaction.prototype.setMap = function(map) {
this.map_ = map;
};
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.