From ec33ac4a84cf4509bd614616896c2b25c4e98315 Mon Sep 17 00:00:00 2001 From: euzuro Date: Wed, 12 Jul 2006 00:16:14 +0000 Subject: [PATCH] give Control classes same setMap() functionality as Layer git-svn-id: http://svn.openlayers.org/trunk/openlayers@936 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control.js | 10 ++++++++++ lib/OpenLayers/Map.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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) {