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 */