OpenLayers OpenLayers

Ticket #1029: mouseposition.2.patch

File mouseposition.2.patch, 1.8 kB (added by crschmidt, 1 year ago)
  • tests/Control/test_MousePosition.html

    old new  
    3737        t.eq(parseInt(map.viewPortDiv.lastChild.style.zIndex), map.Z_INDEX_BASE['Control'] + 5, "Viewport div contains control div"); 
    3838    } 
    3939 
     40    function test_02_Control_MousePosition_redraw_noLayer_displayProjection(t) { 
     41        t.plan(3); 
     42        control = new OpenLayers.Control.MousePosition(); 
     43        map = new OpenLayers.Map('map'); 
     44        map.addControl(control); 
     45        t.eq(control.div.innerHTML, "0.00000, 0.00000", "innerHTML set correctly"); 
     46        control.redraw({'xy': new OpenLayers.Pixel(10,10)}); 
     47        control.redraw({'xy': new OpenLayers.Pixel(12,12)}); 
     48        t.eq(control.div.innerHTML, "0.00000, 0.00000", "innerHTML set correctly"); 
     49        l = new OpenLayers.Layer('name', {'isBaseLayer': true}); 
     50        map.addLayer(l); 
     51        map.zoomToMaxExtent(); 
     52        control.redraw({'xy': new OpenLayers.Pixel(10,10)}); 
     53        control.redraw({'xy': new OpenLayers.Pixel(12,12)}); 
     54        t.eq(control.div.innerHTML, "-175.78125, 85.78125", "innerHTML set correctly when triggered."); 
     55    } 
     56 
    4057  </script> 
    4158</head> 
    4259<body> 
  • lib/OpenLayers/Control/MousePosition.js

    old new  
    108108            } 
    109109 
    110110            lonLat = this.map.getLonLatFromPixel(evt.xy); 
     111            if (!lonLat) {  
     112                // map has not yet been properly initialized 
     113                return; 
     114            }     
    111115            this.lastXy = evt.xy; 
    112116        } 
    113117