Prevent popups from failing when getLayerPxFromLonLat returns null (which is possible

in the case of a not-yet-setup layer, for example).


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4251 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-09-12 20:48:28 +00:00
parent ebc60202b7
commit aa70587033
2 changed files with 17 additions and 1 deletions

View File

@@ -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);
}
}
},

View File

@@ -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 @@
</script>
</head>
<body>
<div id="map" style="width:512px; height:256px"> </div>
</body>
</html>