Changeset 2263
- Timestamp:
- 02/22/07 11:03:47 (2 years ago)
- Files:
-
- sandbox/emanuel/animatedZooming (copied) (copied from trunk/openlayers)
- sandbox/emanuel/animatedZooming/demo.html (added)
- sandbox/emanuel/animatedZooming/demo_frida.html (added)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js (modified) (4 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/PanZoomBar.js (modified) (5 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js (modified) (2 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Grid.js (modified) (6 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Image.js (modified) (1 diff)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/WMS.js (modified) (2 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/WMS/Untiled.js (modified) (3 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Map.js (modified) (11 diffs)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Tile/Image.js (modified) (1 diff)
- sandbox/emanuel/animatedZooming/lib/OpenLayers/Util.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/OverviewMap.js
r2228 r2263 385 385 (this.ovmap.getExtent().containsBounds(testExtent))); 386 386 }, 387 388 updateOverview: function() { 389 var mapRes = this.map.getResolution(); 387 388 /* 389 * Updates the overview map. If the map is scaling (by zooming) the parameters 390 * define the values of the new resolution and bounds. 391 * 392 * @param {float} newResolution 393 * @param {OpenLayers.Bounds} bounds 394 */ 395 updateOverview: function(newResolution, bounds) { 396 //set new map resolution only by scaling 397 if (newResolution) 398 var mapRes = newResolution; 399 else 400 var mapRes = this.map.getResolution(); 390 401 var targetRes = this.ovmap.getResolution(); 391 402 var resRatio = targetRes / mapRes; … … 399 410 this.ovmap.setCenter(this.map.center, 400 411 this.ovmap.getZoomForResolution(targetRes)); 401 this.updateRectToMap( );412 this.updateRectToMap(bounds); 402 413 }, 403 414 … … 423 434 424 435 /** 425 * Updates the extent rectangle position and size to match the map extent 426 */ 427 updateRectToMap: function() { 436 * Updates the extent rectangle position and size to match the map extent 437 * If the map is scaling (by zooming) the parameter defines the 438 * new bounds of the current map 439 * 440 * @param {OpenLayers.Bounds} bounds 441 */ 442 updateRectToMap: function(bounds) { 428 443 // The base layer for overview map needs to be in the same projection 429 444 // as the base layer for the main map. This should be made more robust. … … 433 448 } 434 449 } 435 var pxBounds = this.getRectBoundsFromMapBounds(this.map.getExtent()); 450 451 if (!bounds) 452 bounds=this.map.getExtent(); 453 var pxBounds = this.getRectBoundsFromMapBounds(bounds); 436 454 if (pxBounds) { 437 455 this.setRectPxBounds(pxBounds); sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/PanZoomBar.js
r1721 r2263 24 24 zoomStopHeight: 11, 25 25 26 /** @type int */ 27 zoomlevel_startScale: null, 28 29 /** @type float */ 30 zoomlevel_scale: null, 31 32 /** @type OpenLayers.Size */ 33 tileSize_startScale: null, 34 35 /** @type OpenLayers.Size */ 36 tileSize_scale: null, 37 38 /** @type OpenLayers.Tile */ 39 centerTile: null, 40 41 /** @type float */ 42 resolution_scale: null, 43 26 44 initialize: function() { 27 45 OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments); 28 46 this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X, 29 47 OpenLayers.Control.PanZoomBar.Y); 48 this.tileSize_scale = new OpenLayers.Size(); 30 49 }, 31 50 … … 168 187 this.zoomStart = evt.xy.clone(); 169 188 this.div.style.cursor = "move"; 189 190 // get current zoomlevel 191 this.zoomlevel_startScale = this.map.zoom; 192 193 // get current tile size (it's the base for scaling) 194 this.tileSize_startScale = this.map.baseLayer.getTileSize(); 195 196 // get tile, which contains the center of the viewport 197 this.centerTile = this.map.baseLayer.getCenterTile(); 198 199 //set all active overlays temporarily invisible 200 for (var i = 0; i < this.map.layers.length; i++) { 201 var layer = this.map.layers[i]; 202 if (!layer.isBaseLayer) { 203 this.map.layers[i].div.style.display = "none"; 204 } 205 } 206 170 207 OpenLayers.Event.stop(evt); 171 208 }, … … 187 224 } 188 225 this.mouseDragStart = evt.xy.clone(); 226 227 228 // scale baselayer if tileSize and centerTile is set 229 if ( this.tileSize_startScale && this.centerTile ) { 230 231 // determine zoomlevel 232 this.calculateNewZoomlevel(evt); 233 234 // determine tile size and map resolution 235 this.calculateNewTileSize(); 236 237 // scale (center) tile to new scaled size 238 this.map.baseLayer.scaleTileTo(this.centerTile, 239 this.tileSize_scale); 240 241 // scale all tiles to new scaled size (if there 242 // are more than one tile) 243 this.map.baseLayer.scaleTilesOfGrid(this.centerTile, 244 this.tileSize_scale); 245 246 // scale zoomOut tile (to prevent a white frame during zoomOut) 247 this.map.baseLayer.scaleZoomOutTile(this.tileSize_scale, 248 this.zoomlevel_scale, 249 this.resolution_scale); 250 251 // set new scaled map resolution (important for overviewmap) 252 this.map.setScaleResolution(this.resolution_scale); 253 } 254 189 255 OpenLayers.Event.stop(evt); 190 256 } … … 203 269 this.map.events.unregister("mousemove", this, this.passEventToSlider); 204 270 var deltaY = this.zoomStart.y - evt.xy.y 271 272 // clone layerContainer for "smooth tile update" without blank map 273 this.map.baseLayer.cloneLayerContainer(); 274 275 // zoom map to new zoomlevel 205 276 this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight)); 206 277 this.moveZoomBar(); … … 210 281 }, 211 282 283 284 /** 285 * Calculates new zoomlevel of current zoomslider position. 286 * 287 */ 288 calculateNewZoomlevel:function(evt) { 289 // convert current sliderposition to new zoomlevel 290 var deltaY_zoomlevel = this.zoomStart.y - evt.xy.y; 291 this.zoomlevel_scale = this.zoomlevel_startScale + 292 deltaY_zoomlevel/this.zoomStopHeight; 293 294 // check zoomlevel validity 295 if (this.zoomlevel_scale < 0) { 296 this.zoomlevel_scale = 0; 297 } 298 if (this.zoomlevel_scale > (this.map.getNumZoomLevels()-1)) { 299 this.zoomlevel_scale = this.map.getNumZoomLevels() - 1; 300 } 301 }, 302 303 304 /** 305 * Calculates new tile size and map resolution of current zoomlevel. 306 * 307 */ 308 calculateNewTileSize:function() { 309 // calculate new tile size for... 310 // ...zoomIn 311 if (this.zoomlevel_startScale < this.zoomlevel_scale) { 312 this.tileSize_scale.w = Math.pow(2,(this.zoomlevel_scale - 313 this.zoomlevel_startScale)) * this.tileSize_startScale.w; 314 this.tileSize_scale.h = Math.pow(2,(this.zoomlevel_scale - 315 this.zoomlevel_startScale)) * this.tileSize_startScale.h; 316 317 // set new map resolution 318 this.resolution_scale = 1/(Math.pow(2,(this.zoomlevel_scale - 319 this.zoomlevel_startScale))) * this.map.getResolution(); 320 } 321 // ...zoomOut / no zoom changes 322 if (this.zoomlevel_startScale >= this.zoomlevel_scale) { 323 this.tileSize_scale.w = 1/(Math.pow(2,(this.zoomlevel_startScale - 324 this.zoomlevel_scale))) * this.tileSize_startScale.w; 325 this.tileSize_scale.h = 1/(Math.pow(2,(this.zoomlevel_startScale - 326 this.zoomlevel_scale))) * this.tileSize_startScale.h; 327 328 // set new map resolution 329 this.resolution_scale = Math.pow(2,(this.zoomlevel_startScale - 330 this.zoomlevel_scale)) * this.map.getResolution(); 331 } 332 }, 333 334 212 335 /* 213 336 * Change the location of the slider to match the current zoom level. sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer.js
r2233 r2263 131 131 this.div.id = this.id; 132 132 } 133 134 this.events = new OpenLayers.Events(this, this.div, this.EVENT_TYPES); 133 134 this.events = new OpenLayers.Events(this, this.div,this.EVENT_TYPES); 135 this.events.register("loadend", this, this.setLoadendVisibility); 136 135 137 }, 136 138 … … 577 579 this.div.style.zIndex = zIdx; 578 580 }, 581 582 583 584 585 /********************************************************/ 586 /* */ 587 /* Baselayer Functions for zooming/scaling */ 588 /* */ 589 /********************************************************/ 590 591 /** 592 * Initializes zoomOut tile and sets a x-times bigger tile size. 593 * 594 * Default function; will override in subclasses, 595 * otherwise it returns false 596 * 597 * @returns false if no zoomOutTile is set 598 * @type Boolean 599 */ 600 setZoomOutTile:function() { 601 return false; 602 }, 603 604 /** 605 * Initializes zoomOut tile and sets a x-times bigger tile size. 606 * 607 * special function; shares with some baselayers; calls from subclasses 608 * 609 */ 610 setZoomOutTile_share:function() { 611 if (!this.zoomOutTile) { 612 var bounds = this.map.getMaxExtent(); 613 var resolution = this.resolutions[0]; 614 615 // calculate tile bounds 616 var n = 0; 617 do { 618 resolution = resolution * Math.pow(2, n); 619 620 var tilelon = resolution * this.map.tileSize.w; 621 var tilelat = resolution * this.map.tileSize.h; 622 623 var tileoffsetlon = bounds.left; 624 var tileoffsetlat = bounds.bottom; 625 626 var tileBounds = new OpenLayers.Bounds(tileoffsetlon, 627 tileoffsetlat, 628 tileoffsetlon + tilelon, 629 tileoffsetlat + tilelat); 630 n++; 631 } 632 while (!tileBounds.containsBounds(bounds, false, true)); 633 634 var tileSize = new OpenLayers.Size(); 635 tileSize.w = this.map.zoomOutTileSizeFactor * this.map.tileSize.w; 636 tileSize.h = this.map.zoomOutTileSizeFactor * this.map.tileSize.h; 637 638 // formulate request url string 639 var url = this.getURL(tileBounds, tileSize); 640 // default start position 641 var pos = new OpenLayers.Pixel (0,0); 642 // default start size 643 var tilesize = new OpenLayers.Size(0,0); 644 645 this.zoomOutTile = new OpenLayers.Tile.Image(this, pos, tileBounds, 646 url, tileSize); 647 648 // draw tile -> sets imgDiv 649 this.zoomOutTile.draw(); 650 651 // resize zoomOutTile 652 this.zoomOutTile.imgDiv.style.width = 0; 653 this.zoomOutTile.imgDiv.style.height = 0; 654 } 655 }, 656 657 /** 658 * Gets the current tile size of the layer. 659 * 660 * Default function; will override in subclasses, 661 * otherwise it returns false - that means: no scaling possible! 662 * 663 * @returns null if no tile size set 664 * @type OpenLayers.Size 665 */ 666 getTileSize:function() { 667 return null; 668 }, 669 670 /** 671 * Clones layerContainer for "smooth tile update". 672 * So, it gets no blank map while map is loading in new zoomlevel. 673 * 674 * Default function; will override in subclasses, 675 * otherwise it returns false 676 * 677 * @returns false if no layerContainer cloned 678 * @type Boolean 679 */ 680 cloneLayerContainer:function() { 681 return false; 682 }, 683 684 /** 685 * The actual clone function: 686 * Freeze current map while tiles of viewport are loading. 687 * 688 * special function; shares with some baselayers; calls from subclasses 689 * 690 */ 691 cloneLayerContainer_share:function() { 692 // 1. clone layerContainerDiv with all childs (replace, if already exist) 693 if (this.map.layerContainerDivClone){ 694 this.map.viewPortDiv.removeChild(this.map.layerContainerDivClone); 695 this.map.layerContainerDivClone = null; 696 } 697 this.map.layerContainerDivClone = this.map.layerContainerDiv.cloneNode(true); 698 this.map.layerContainerDivClone.id = "map_OpenLayers_Container_clone"; 699 // 2. append layerContainerDivClone to viewPortDiv 700 // (now the cloned div is above the original; it hides the original) 701 this.map.viewPortDiv.appendChild(this.map.layerContainerDivClone); 702 }, 703 704 705 /** 706 * Sets visibility after zoomend/loadend: 707 * - freezed/cloned layerContainer invisible 708 * - zoomOutTile invisibile 709 * Calls automatically after fire loadend event. 710 */ 711 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"; 720 } 721 }, 722 723 /** 724 * Gets tile, which contains the center of the viewport. 725 * 726 * Default function; will override in subclasses, 727 * otherwise it returns null - that means: no scaling possible! 728 * 729 * @returns returns null if no center tile set 730 * @type OpenLayers.Tile 731 */ 732 getCenterTile:function() { 733 return null; 734 }, 735 736 /** 737 * Scales tile to the new tile size (changes size and position). 738 * If you have a grid, the tile is the center tile. Otherwise it's 739 * the only one. 740 * 741 * @param {OpenLayers.Tile} tile 742 * @param {OpenLayers.Size} newTileSize 743 * 744 * @returns true if tile is scaled, otherwise false 745 * @type Boolean 746 */ 747 scaleTileTo:function(tile, newTileSize) { 748 749 //convert the center of the map in pixel 750 var centerPx = this.map.getPixelFromLonLat(this.map.getCenter()); 751 752 //reposition and resize the tile 753 if (tile) { 754 // set real start position of centerTile 755 var startPosX = (tile.position.x + 756 parseInt(this.map.layerContainerDiv.style.left)); 757 // set new left position 758 var leftOffset = newTileSize.w / tile.size.w 759 * (centerPx.x - startPosX); 760 leftOffset = Math.round(leftOffset); 761 var newLeftPos = centerPx.x - leftOffset 762 - parseInt(this.map.layerContainerDiv.style.left); 763 tile.imgDiv.style.left = newLeftPos + "px"; 764 765 // set real start position of centerTile 766 var startPosY = (tile.position.y + 767 parseInt(this.map.layerContainerDiv.style.top)); 768 //set new top position 769 var topOffset = newTileSize.h / tile.size.h 770 * (centerPx.y - startPosY); 771 topOffset = Math.round(topOffset); 772 var newTopPos = centerPx.y - topOffset 773 - parseInt(this.map.layerContainerDiv.style.top); 774 tile.imgDiv.style.top = newTopPos + "px"; 775 776 //set new width and height 777 tile.imgDiv.style.width = newTileSize.w + "px"; 778 tile.imgDiv.style.height = newTileSize.h + "px"; 779 780 return true; 781 } 782 else { 783 return false; 784 } 785 }, 786 787 /** 788 * Scales all tiles of a grid to the new tile size 789 * (changes size and position). 790 * 791 * Default function; will override in subclasses, 792 * otherwise it returns false 793 * 794 * @param {OpenLayers.Tile} centerTile 795 * @param {OpenLayers.Size} newTileSize 796 * 797 * @returns false if no grid is scaled 798 * @type Boolean 799 */ 800 scaleTilesOfGrid:function(centertile, newTileSize) { 801 return false; 802 }, 803 804 805 /** 806 * Reposition and resize the zoomOut tile to prevent a white frame 807 * during zoomOut. 808 * 809 * @param {OpenLayers.Size} newTileSize 810 * @param {float} newZoomlevel 811 * @param {float} newResolution 812 * 813 * @returns false if no zoomOutTile scaled 814 * @type Boolean 815 */ 816 scaleZoomOutTile: function(newTileSize, newZoomlevel, newResolution) { 817 return false; 818 }, 819 820 /** 821 * The actual zoomOutTile scale function: 822 * Reposition and resize the zoomOut tile to prevent a white frame 823 * during zoomOut. 824 * 825 * special function; shares with some baselayers; calls from subclasses 826 * 827 * @param {OpenLayers.Size} newTileSize 828 * @param {float} newZoomlevel 829 * @param {float} newResolution 830 * 831 * @returns true after the zoomOutTile is scaled 832 * @type Boolean 833 */ 834 scaleZoomOutTile_share: function(newTileSize, newZoomlevel, newResolution) { 835 836 //convert the current center of the map in pixel 837 var centerPx = this.map.getPixelFromLonLat(this.map.getCenter()); 838 839 //set new size (width and height) 840 this.zoomOutTile.imgDiv.style.width = this.map.tileSize.w 841 * Math.pow(2, newZoomlevel) + "px"; 842 this.zoomOutTile.imgDiv.style.height = this.map.tileSize.h 843 * Math.pow(2, newZoomlevel) + "px"; 844 845 //set new position (top and left) 846 var bounds = this.zoomOutTile.bounds; 847 var extent = this.map.getExtent(); 848 var maxExtent = this.map.getMaxExtent(); 849 850 var resolution = this.map.getMaxResolution(); 851 var centerLonLat = extent.getCenterLonLat(); 852 853 if( bounds.containsLonLat(centerLonLat) 854 && !(extent.equals(maxExtent))) { 855 var offsetlon = bounds.left - centerLonLat.lon; 856 var offsetlat = -bounds.top + centerLonLat.lat; 857 858 var offsetx = offsetlon / newResolution 859 - parseInt(this.map.layerContainerDiv.style.left); 860 var offsety = offsetlat / newResolution 861 - parseInt(this.map.layerContainerDiv.style.top); 862 863 this.zoomOutTile.imgDiv.style.left = centerPx.x + offsetx + "px"; 864 this.zoomOutTile.imgDiv.style.top = centerPx.y + offsety + "px"; 865 866 // set zoomOutTile visible if viewport < map bounds 867 if ( (bounds.left < extent.left) || (bounds.right > extent.right) ) 868 this.map.baseLayer.zoomOutTile.imgDiv.style.display = "block"; 869 else 870 this.map.baseLayer.zoomOutTile.imgDiv.style.display = "none"; 871 } 872 873 return true; 874 }, 875 579 876 580 877 /** @final @type String */ sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Grid.js
r2237 r2263 23 23 /** @type Integer */ 24 24 buffer: 2, 25 26 /** @type Integer */ 27 centerRow: null, 28 29 /** @type Integer */ 30 centerCol: null, 25 31 26 32 /** … … 139 145 } 140 146 }, 147 141 148 142 149 /** … … 259 266 } 260 267 } 261 268 269 262 270 //now actually draw the tiles 263 271 this.spiralTileLoad(); … … 274 282 * and iterate through the queue (thus reversing the spiral order from 275 283 * outside-in to inside-out), calling draw() on each tile. 284 * 285 * Fires loadend event after all tiles in viewport loaded. 276 286 */ 277 287 spiralTileLoad: function() { … … 314 324 315 325 if ((tile != null) && (!tile.queued)) { 316 // add tile to beginning of queue, mark it as queued.326 // add tile to beginning of queue, mark it as queued. 317 327 tileQueue.unshift(tile); 318 328 tile.queued = true; 319 329 320 // restart the directions counter and take on the new coords330 // restart the directions counter and take on the new coords 321 331 directionsTried = 0; 322 332 iRow = testRow; 323 333 iCell = testCell; 324 334 } else { 325 // need to try to load a tile in a different direction335 // need to try to load a tile in a different direction 326 336 direction = (direction + 1) % 4; 327 337 directionsTried++; 328 338 } 329 339 } 330 340 341 // fire loadstart event 342 this.events.triggerEvent("loadstart"); 343 this.doneLoading = false; 344 345 // set tileQueue temporary as class parameter; 346 // necessaray to get values also in onload event function 347 this.tileQueue = tileQueue; 348 331 349 // now we go through and draw the tiles in forward order 332 350 for(var i=0; i < tileQueue.length; i++) { 333 var tile = tileQueue[i] 334 tile.draw(); 335 //mark tile as unqueued for the next time (since tiles are reused) 336 tile.queued = false; 351 var drawn = tileQueue[i].draw(); 352 // mark tile as unqueued for the next time (since tiles are reused) 353 tileQueue[i].queued = false; 354 355 356 // onload event function; 357 // it calls automatically when image fires onload event 358 var onload = function() { 359 // get object array 360 var tile = this[0]; 361 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; 378 } 379 } 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"); 386 } 387 } 388 389 390 // if tile is start drawing (imgDiv exists)... 391 if (drawn){ 392 // create an object with current tile and layer for onload event 393 var object = new Array(); 394 object[0] = tileQueue[i]; 395 object[1] = this; 396 397 // start onload event listener 398 OpenLayers.Event.observe(tileQueue[i].imgDiv, 'load', 399 onload.bindAsEventListener(object)); 400 } 337 401 } 338 402 }, … … 449 513 }, 450 514 515 516 517 /********************************************************/ 518 /* */ 519 /* Baselayer Functions for zooming/scaling */ 520 /* */ 521 /********************************************************/ 522 523 /** 524 * Initializes zoomOut tile and sets a x-times bigger tile size. 525 * 526 * @returns true after zoomOutTile is set 527 * @type Boolean 528 */ 529 setZoomOutTile:function() { 530 this.setZoomOutTile_share(); 531 return true; 532 }, 533 534 /** 535 * Gets the current tile size of the layer. 536 * 537 * @returns the current map tile size 538 * @type OpenLayers.Size 539 */ 540 getTileSize:function() { 541 return this.map.getTileSize(); 542 }, 543 544 /** 545 * Gets tile, which contains the center of the viewport. 546 * 547 * @returns the tile, which contains the center of the viewport 548 * @type OpenLayers.Tile 549 */ 550 getCenterTile:function() { 551 if (this.grid) { 552 for (var iRow=0; iRow < this.grid.length; iRow++) { 553 for (var iCol=0; iCol < this.grid[iRow].length; iCol++) { 554 var tileBounds = this.grid[iRow][iCol].bounds; 555 if (tileBounds.containsLonLat(this.map.getCenter(), true)) { 556 this.centerRow = iRow; 557 this.centerCol = iCol; 558 return this.grid[iRow][iCol]; 559 } 560 } 561 } 562 } 563 return false; // something runs fail! 564 }, 565 566 /** 567 * Scales all tiles of a grid to the new tile size 568 * (changes size and position). 569 * 570 * @param {OpenLayers.Tile} centerTile 571 * @param {OpenLayers.Size} newTileSize 572 * 573 * @returns true after the grid is scaled 574 * @type Boolean 575 */ 576 scaleTilesOfGrid:function(centerTile, newTileSize) { 577 578 var extent = this.map.getExtent(); 579 580 // reposition and resize all _visible_ tiles of the active baselayer 581 var layerGrid = this.map.baseLayer.grid; 582 583 // go through the whole grid 584 for (var iRow=0; iRow < layerGrid.length; iRow++) { 585 for (var iCol=0; iCol < layerGrid[iRow].length; iCol++) { 586 var tile = layerGrid[iRow][iCol]; 587 if (tile.imgDiv) { 588 // scale all (visible) tiles within the viewport 589 if (extent.containsBounds(tile.bounds,true, false)) { 590 //define the factors for rows and columns 591 //(relates to the center tile) 592 var deltaRow = iRow - this.centerRow; 593 var deltaCol = iCol - this.centerCol; 594 595 //set new left position 596 var newLeftPos = parseInt(centerTile.imgDiv.style.left) 597 + deltaCol * newTileSize.w ; 598 tile.imgDiv.style.left = newLeftPos + "px"; 599 600 //set new top position 601 var newTopPos = parseInt(centerTile.imgDiv.style.top) 602 + deltaRow * newTileSize.h ; 603 tile.imgDiv.style.top = newTopPos + "px"; 604 605 //set new width and height 606 tile.imgDiv.style.width = newTileSize.w + "px"; 607 tile.imgDiv.style.height = newTileSize.h + "px"; 608 } 609 } 610 } 611 } 612 return true; 613 }, 614 615 /** 616 * Reposition and resize the zoomOut tile to prevent a white frame 617 * during zoomOut. 618 * share scale algorithm with other baselayers 619 * 620 * @param {OpenLayers.Size} newTileSize 621 * @param {float} newZoomlevel 622 * @param {float} newResolution 623 * 624 * @returns true if zoomOutTile is scaled, otherwise false 625 * @type Boolean 626 */ 627 scaleZoomOutTile: function(newTileSize, newZoomlevel, newResolution) { 628 if (this.zoomOutTile) { 629 this.scaleZoomOutTile_share(newTileSize, newZoomlevel, newResolution); 630 return true; 631 } 632 else { 633 return false; 634 } 635 }, 636 637 /** 638 * Clones layerContainer for "smooth tile update". 639 * So, it gets no blank map while map is loading in new zoomlevel. 640 * 641 * @returns true after layerContainer is cloned 642 * @type Boolean 643 */ 644 cloneLayerContainer:function() { 645 // share clone algorithm with other baselayers 646 this.cloneLayerContainer_share(); 647 648 // remove all old imgDiv tiles 649 // (so it doesn't becomes complicate with the same imgDivs of the 650 // cloned layerContainerDiv) 651 for (iRow=0; iRow<this.grid.length; iRow++){ 652 for (iCol=0; iCol<this.grid[iRow].length; iCol++){ 653 var tile = this.grid[iRow][iCol]; 654 if (tile.imgDiv) 655 this.div.removeChild(tile.imgDiv); 656 } 657 } 658 //reset grid array 659 this.grid = new Array(); 660 661 return true; 662 }, 663 664 665 451 666 /** @final @type String */ 452 667 CLASS_NAME: "OpenLayers.Layer.Grid" sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/Image.js
r2090 r2263 157 157 }, 158 158 159 160 161 /********************************************************/ 162 /* */ 163 /* Baselayer Functions for zooming/scaling */ 164 /* */ 165 /********************************************************/ 166 167 168 /** 169 * gets tile (image) size 170 * 171 * @returns the image size 172 */ 173 getTileSize:function() { 174 return this.tile.size; 175 }, 176 177 /** 178 * 179 * @returns the only tile of the layer 180 * @type {OpenLayers.Tile} 181 */ 182 getCenterTile:function() { 183 return this.tile; 184 }, 185 186 159 187 /** @final @type String */ 160 188 CLASS_NAME: "OpenLayers.Layer.Image" sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/WMS.js
r2237 r2263 86 86 /** 87 87 * @param {OpenLayers.Bounds} bounds 88 * @param {OpenLayers.Size} tileSize 88 89 * 89 90 * @returns A string with the layer's url and parameters and also the … … 92 93 * @type String 93 94 */ 94 getURL: function (bounds) { 95 getURL: function (bounds,tileSize) { 96 if (!tileSize) { 97 var tileSize = this.tileSize; 98 } 95 99 return this.getFullRequestString( 96 100 {BBOX:bounds.toBBOX(), 97 WIDTH:t his.tileSize.w,98 HEIGHT:t his.tileSize.h});101 WIDTH:tileSize.w, 102 HEIGHT:tileSize.h}); 99 103 }, 100 104 sandbox/emanuel/animatedZooming/lib/OpenLayers/Layer/WMS/Untiled.js
r2226 r2263 32 32 tile: null, 33 33 34 /** did the image finish loading before a new draw was initiated?35 * @type Boolean */36 doneLoading: false,37 34 38 35 /** … … 165 162 } 166 163 164 // fire loadstart event 167 165 this.events.triggerEvent("loadstart"); 168 166 this.doneLoading = false; 169 if (!this.tile) { 167 168 if (!this.tile){ 170 169 this.tile = new OpenLayers.Tile.Image(this, pos, tileBounds, 171 170 url, tileSize); 172 this.tile.draw(); 171 var drawn = this.tile.draw(); 172 173 173 var onload = function() { 174 174 this.doneLoading = true; 175 175 this.events.triggerEvent("loadend"); 176 176 } 177 177 178 OpenLayers.Event.observe(this.tile.imgDiv, 'load', 178 179 onload.bindAsEventListener(this)); 180 179 181 } else { 180 182 this.tile.moveTo(tileBounds, pos); 181 183 } 182 183 } 184 }, 185 186 getURL: function(bounds) { 187 var tileSize = this.map.getSize(); 188 tileSize.w = tileSize.w * this.ratio; 189 tileSize.h = tileSize.h * this.ratio; 184 } 185 }, 186 187
