From bf8c1fba0287379b640415612572bd236ee8d6e8 Mon Sep 17 00:00:00 2001 From: euzuro Date: Thu, 25 May 2006 02:43:56 +0000 Subject: [PATCH] give Popup an 'updatePosition()' function that allows it to re-position itself. This will be used for zoom changes. git-svn-id: http://svn.openlayers.org/trunk/openlayers@350 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 4 +--- lib/OpenLayers/Popup.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index 4aa1de3748..96ada8dbbc 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -394,9 +394,7 @@ OpenLayers.Map.prototype = { //redraw popups for (var i = 0; i < this.popups.length; i++) { - var popup = this.popups[i]; - var px = this.getLayerPxFromLonLat(popup.lonlat); - popup.moveTo(px); + this.popups[i].updatePosition(); } } diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 56e56aea39..7810026966 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -103,6 +103,17 @@ OpenLayers.Popup.prototype = { return this.div; }, + /** + * if the popup has a lonlat and its map members set, + * then have it move itself to its proper position + */ + updatePosition: function() { + if ((this.lonlat) && (this.map)) { + px = this.map.getLayerPxFromLonLat(this.lonlat); + this.moveTo(px); + } + }, + /** * @param {OpenLayers.Pixel} px */