diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index 117fb26c45..379b14c720 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -24,6 +24,16 @@ OpenLayers.Control.prototype = { Object.extend(this, options); }, + /** Set the map property for the control. This is done through an accessor + * so that subclasses can override this and take special action once + * they have their map variable set. + * + * @param {OpenLayers.Map} map + */ + setMap: function(map) { + this.map = map; + }, + /** * @param {OpenLayers.Pixel} px * diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 17c89b6c5e..010e582bde 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -318,7 +318,7 @@ OpenLayers.Map.prototype = { * @param {OpenLayers.Pixel} px */ addControl: function (control, px) { - control.map = this; + control.setMap(this); this.controls.push(control); var div = control.draw(px); if (div) {