diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index ffd074e691..156d423546 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -226,7 +226,9 @@ OpenLayers.Popup = OpenLayers.Class({ updatePosition: function() { if ((this.lonlat) && (this.map)) { var px = this.map.getLayerPxFromLonLat(this.lonlat); - this.moveTo(px); + if (px) { + this.moveTo(px); + } } }, diff --git a/tests/test_Popup.html b/tests/test_Popup.html index d16249bafa..e2484c860e 100644 --- a/tests/test_Popup.html +++ b/tests/test_Popup.html @@ -51,6 +51,19 @@ t.eq(popup.contentHTML, content, "contentHTML porpoerty of set correctly"); } + function test_Popup_updatePosition(t) { + t.plan(1) + var map = new OpenLayers.Map('map'); + map.addLayer(new OpenLayers.Layer('name', {'isBaseLayer':true})); + map.zoomToMaxExtent(); + var popup = new OpenLayers.Popup('id'); + map.addPopup(popup); + map.getLayerPxFromLonLat = function () { return null; } + popup.moveTo=function() { t.fail("Shouldnt' call moveTo if layerpx is null"); } + popup.lonlat = true; + popup.updatePosition(); + t.ok(true, "update position doesn't fail when getLayerPxFromLonLat fails."); + } function test_03_Popup_draw(t) { t.plan( 17 ); @@ -109,5 +122,6 @@ +