OpenLayers OpenLayers

Changeset 1358

Show
Ignore:
Timestamp:
08/24/06 11:07:18 (2 years ago)
Author:
crschmidt
Message:

If we turn on the zooming tool, then click on the panzoombar in IE,
because the click drops through (Why god Why?!) we get an error telling
us that evt.xy doesn't exist, so we wrap it in an if statement which
protects us. (Deliver us, o if statement, from IEvil...)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/openlayers/2.0/lib/OpenLayers/Control/MouseDefaults.js

    r1357 r1358  
    167167     */ 
    168168    zoomBoxEnd: function(evt) { 
    169         if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||     
    170             Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {    
    171             var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );  
    172             var end = this.map.getLonLatFromViewPortPx( evt.xy ); 
    173             var top = Math.max(start.lat, end.lat); 
    174             var bottom = Math.min(start.lat, end.lat); 
    175             var left = Math.min(start.lon, end.lon); 
    176             var right = Math.max(start.lon, end.lon); 
    177             var bounds = new OpenLayers.Bounds(left, bottom, right, top); 
    178             var zoom = this.map.getZoomForExtent(bounds); 
    179             this.map.setCenter(new OpenLayers.LonLat( 
    180               (start.lon + end.lon) / 2, 
    181               (start.lat + end.lat) / 2 
    182              ), zoom); 
    183         } else { 
    184             var end = this.map.getLonLatFromViewPortPx( evt.xy ); 
    185             this.map.setCenter(new OpenLayers.LonLat( 
    186               (end.lon), 
    187               (end.lat) 
    188              ), this.map.getZoom() + 1); 
    189         }     
    190         this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); 
    191         this.zoomBox = null; 
     169        if (this.mouseDragStart != null) { 
     170            if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||     
     171                Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {    
     172                var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );  
     173                var end = this.map.getLonLatFromViewPortPx( evt.xy ); 
     174                var top = Math.max(start.lat, end.lat); 
     175                var bottom = Math.min(start.lat, end.lat); 
     176                var left = Math.min(start.lon, end.lon); 
     177                var right = Math.max(start.lon, end.lon); 
     178                var bounds = new OpenLayers.Bounds(left, bottom, right, top); 
     179                var zoom = this.map.getZoomForExtent(bounds); 
     180                this.map.setCenter(new OpenLayers.LonLat( 
     181                  (start.lon + end.lon) / 2, 
     182                  (start.lat + end.lat) / 2 
     183                 ), zoom); 
     184            } else { 
     185                var end = this.map.getLonLatFromViewPortPx( evt.xy ); 
     186                this.map.setCenter(new OpenLayers.LonLat( 
     187                  (end.lon), 
     188                  (end.lat) 
     189                 ), this.map.getZoom() + 1); 
     190            }     
     191            this.map.viewPortDiv.removeChild(document.getElementById("zoomBox")); 
     192            this.zoomBox = null; 
     193       }      
    192194    }, 
    193195