OpenLayers OpenLayers

Changeset 4251

Show
Ignore:
Timestamp:
09/12/07 16:48:28 (1 year ago)
Author:
crschmidt
Message:

Prevent popups from failing when getLayerPxFromLonLat returns null (which is possible
in the case of a not-yet-setup layer, for example).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Popup.js

    r4115 r4251  
    227227        if ((this.lonlat) && (this.map)) { 
    228228                var px = this.map.getLayerPxFromLonLat(this.lonlat); 
    229                 this.moveTo(px);             
     229                if (px) { 
     230                    this.moveTo(px);            
     231                }     
    230232        } 
    231233    }, 
  • trunk/openlayers/tests/test_Popup.html

    r4157 r4251  
    5252    } 
    5353 
     54    function test_Popup_updatePosition(t) { 
     55        t.plan(1) 
     56        var map = new OpenLayers.Map('map'); 
     57        map.addLayer(new OpenLayers.Layer('name', {'isBaseLayer':true})); 
     58        map.zoomToMaxExtent(); 
     59        var popup = new OpenLayers.Popup('id'); 
     60        map.addPopup(popup); 
     61        map.getLayerPxFromLonLat = function () { return null; } 
     62        popup.moveTo=function() { t.fail("Shouldnt' call moveTo if layerpx is null"); } 
     63        popup.lonlat = true; 
     64        popup.updatePosition(); 
     65        t.ok(true, "update position doesn't fail when getLayerPxFromLonLat fails."); 
     66    } 
    5467    function test_03_Popup_draw(t) { 
    5568        t.plan( 17 ); 
     
    110123</head> 
    111124<body> 
     125<div id="map" style="width:512px; height:256px"> </div> 
    112126</body> 
    113127</html>