OpenLayers OpenLayers

Changeset 2280

Show
Ignore:
Timestamp:
02/23/07 06:35:22 (2 years ago)
Author:
emanuel
Message:

overviewmap features (recenter by dblclick, move by panning), no loadendevent for overviewmap; viewRequestID workaround

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js

    r2275 r2280  
    118118        this.div.appendChild(this.element); 
    119119 
    120         this.map.events.register('moveend', this, this.update); 
     120        // update overviewmap during map is panning 
     121        this.map.events.register('move', this, this.update); 
    121122         
    122         // Set up events.  The image div recenters the map on click. 
     123        // Set up events.  The image div recenters the map on doubleclick. 
    123124        // The extent rectangle can be dragged to recenter the map. 
    124125        // If the mousedown happened elsewhere, then mousemove and mouseup 
     
    142143            OpenLayers.Event.stop(e); 
    143144        }); 
    144         this.rectEvents.register('dblclick', this, this.rectDblClick ); 
    145145        this.mapDivEvents = new OpenLayers.Events(this, this.mapDiv); 
    146         this.mapDivEvents.register('click', this, this.mapDivClick); 
     146        this.mapDivEvents.register('dblclick', this, this.mapDivDblClick ); 
    147147 
    148148        // Optionally add min/max buttons if the control will go in the 
     
    282282    }, 
    283283     
     284 
    284285    /** 
    285286    * @param {OpenLayers.Event} evt 
    286287    */ 
    287     rectDblClick: function(evt) { 
    288         this.performedRectDrag = false; 
    289         OpenLayers.Event.stop(evt); 
    290         this.updateOverview(); 
    291     }, 
    292  
    293     /** 
    294     * @param {OpenLayers.Event} evt 
    295     */ 
    296     mapDivClick: function(evt) { 
     288    mapDivDblClick: function(evt) { 
    297289        var pxBounds = this.getRectPxBounds(); 
    298290        var pxCenter = pxBounds.getCenterPixel(); 
     
    360352        } 
    361353         
    362         if(!this.isSuitableOverview()) { 
    363             this.updateOverview(); 
    364         } 
    365          
    366         // update extent rectangle 
    367         this.updateRectToMap(); 
    368     }, 
    369      
    370     /** 
    371      * Determines if the overview map is suitable given the extent and 
    372      * resolution of the main map. 
    373      */ 
    374     isSuitableOverview: function() { 
    375         var mapExtent = this.map.getExtent(); 
    376         var maxExtent = this.map.maxExtent; 
    377         var testExtent = new OpenLayers.Bounds( 
    378                                 Math.max(mapExtent.left, maxExtent.left), 
    379                                 Math.max(mapExtent.bottom, maxExtent.bottom), 
    380                                 Math.min(mapExtent.right, maxExtent.right), 
    381                                 Math.min(mapExtent.top, maxExtent.top));         
    382         var resRatio = this.ovmap.getResolution() / this.map.getResolution(); 
    383         return ((resRatio > this.minRatio) && 
    384                 (resRatio <= this.maxRatio) && 
    385                 (this.ovmap.getExtent().containsBounds(testExtent))); 
    386     }, 
    387  
     354        this.updateOverview(); 
     355    }, 
     356     
    388357    /*  
    389358     * Updates the overview map. If the map is scaling (by zooming) the parameters 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js

    r2275 r2280  
    704704 
    705705    /** 
    706      * Sets visibility after zoomend/loadend: 
     706     * Sets visibility of map after zoomend/loadend: 
    707707     * - freezed/cloned layerContainer invisible 
    708708     * - zoomOutTile invisibile 
     709     *  
    709710     * Calls automatically after fire loadend event.  
    710711     */ 
    711712    setLoadendVisibility: function() { 
    712         // set cloned layerDiv invisibile -> original div is visible                
    713         if (this.map.layerContainerDivClone){ 
    714             this.map.layerContainerDivClone.style.display= "none"; 
    715         } 
    716  
    717         // set zoomOutTile invisible 
    718         if (this.map.baseLayer.zoomOutTile){ 
    719             this.map.baseLayer.zoomOutTile.imgDiv.style.display = "none"; 
     713        // function for map only; not for overviewmap! 
     714        if (this.map.div.id == "map") {         
     715            // set cloned layerDiv invisibile -> original div is visible                
     716            if (this.map.layerContainerDivClone){ 
     717                this.map.layerContainerDivClone.style.display= "none"; 
     718            } 
     719 
     720            // set zoomOutTile invisible 
     721            if (this.map.baseLayer.zoomOutTile){ 
     722                this.map.baseLayer.zoomOutTile.imgDiv.style.display = "none"; 
     723            } 
    720724        } 
    721725    }, 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Grid.js

    r2275 r2280  
    173173     */ 
    174174    _initTiles:function() { 
    175          
     175        if (this.map.div.id.match("overviewMap"))  
     176            this.buffer = 1; 
     177 
    176178        // work out mininum number of rows and columns; this is the number of 
    177179        // tiles required to cover the viewport plus one for panning 
     
    360362                var tile = this[0]; 
    361363                var layer = this[1]; 
    362  
    363                 // default assumption: every images in extent are loaded 
    364                 var stillLoading = false; 
    365                 
    366                 // set internal alt message after image loaded 
    367                 if (tile.imgDiv) 
    368                     tile.imgDiv.alt = "loaded"; 
    369  
    370                 // check if all visible tiles are loaded 
    371                 for (var j=0; j < layer.tileQueue.length; j++) { 
    372                     if (layer.tileQueue[j].imgDiv){ 
    373                         if((layer.tileQueue[j].bounds.intersectsBounds( 
    374                                             layer.map.getExtent(),false)) 
    375                           && (layer.tileQueue[j].imgDiv.alt != "loaded")){ 
    376                             // at least one image tile is still loading 
    377                             stillLoading = true; 
     364                if (layer.map.div.id == "map") {  
     365                    // default assumption: every images in extent are loaded 
     366                    var stillLoading = false; 
     367                    
     368                    // set internal alt message after image loaded 
     369                    if (tile.imgDiv) 
     370                        tile.imgDiv.alt = "loaded"; 
     371 
     372                    // check if all visible tiles are loaded 
     373                    for (var j=0; j < layer.tileQueue.length; j++) { 
     374                        if (layer.tileQueue[j].imgDiv){ 
     375                            if((layer.tileQueue[j].bounds.intersectsBounds( 
     376                                                layer.map.getExtent(),false)) 
     377                              && (layer.tileQueue[j].imgDiv.alt != "loaded")){ 
     378                                // at least one image tile is still loading 
     379                                stillLoading = true; 
     380                            } 
    378381                        } 
    379382                    } 
    380                 } 
    381  
    382                 // any visible images loaded? -> fire loadend event 
    383                 if ((!stillLoading) && (!layer.map.baseLayer.doneLoading)) { 
    384                     layer.map.baseLayer.doneLoading = true; 
    385                     layer.events.triggerEvent("loadend");  
     383 
     384                    // any visible images loaded? -> fire loadend event 
     385                    if ((!stillLoading) && (!layer.map.baseLayer.doneLoading)) { 
     386                        layer.map.baseLayer.doneLoading = true; 
     387                        layer.events.triggerEvent("loadend");  
     388                    } 
    386389                } 
    387390            } 
  • sandbox/emanuel/animatedZooming/lib/OpenLayers/Util.js

    r2275 r2280  
    230230    // this code that turns its display on). 
    231231    // 
    232     if (!this.viewRequestID || 
    233         (this.viewRequestID == this.map.viewRequestID)) {  
     232    var request; 
     233    if (!this.viewRequestID) 
     234        request = true; 
     235         
     236    if (this.map) { 
     237        if (this.viewRequestID == this.map.viewRequestID)  
     238            request = true; 
     239    } 
     240 
     241    if (request) { 
    234242        this.style.backgroundColor = null; 
    235243        this.style.display = "";