OpenLayers OpenLayers

Changeset 1208

Show
Ignore:
Timestamp:
08/14/06 22:15:03 (2 years ago)
Author:
crschmidt
Message:

Since VirtualEarth doesn't understand bounds at all, this function didn't work.
This is not an ideal situation, becauuse it's not really 100% correct for a
mercator projection, but it does cause things to work.

It seems that for some reason, the EventPane isn't actually catching all the
move events -- this seems to be what is causing the slow dragging. I'm not
sure of the reason for this, but maybe Erik or someone else will be able to
offer hints. I could also just be wrong ;) I just know it's slow, really.

Files:

Legend:

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

    r1207 r1208  
    213213     */ 
    214214    getZoomForExtent: function (bounds) { 
    215         var zoom = null; 
    216         if (this.vemap != null) { 
    217             var gBounds = this.getVELatLongBoundsFromOLBounds(bounds); 
    218             var gZoom = this.vemap.getBoundsZoomLevel(gBounds); 
    219             zoom = this.getOLZoomFromGZoom(gZoom); 
    220         } 
     215 
     216        var maxRes = this.map.getMaxResolution(); 
     217        var viewSize = this.map.getSize(); 
     218 
     219        var width = bounds.getWidth(); 
     220        var height = bounds.getHeight(); 
     221 
     222        var degPerPixel = (width > height) ? width / viewSize.w  
     223                                           : height / viewSize.h; 
     224         
     225        var zoom = Math.floor( (Math.log(maxRes/degPerPixel)) / Math.log(2) ); 
     226 
     227        var maxZoomLevel = this.map.getMaxZoomLevel(); 
     228        var minZoomLevel = this.map.getMinZoomLevel(); 
     229     
     230        //make sure zoom is within bounds     
     231        zoom = Math.min( Math.max(zoom, minZoomLevel),  
     232                         maxZoomLevel ); 
     233 
    221234        return zoom; 
    222235    },