Changeset 2091
- Timestamp:
- 12/22/06 13:35:04 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (4 diffs)
- trunk/openlayers/lib/OpenLayers/Tile.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Tile/Image.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Tile/WFS.js (modified) (1 diff)
- trunk/openlayers/tests/test_Tile_Image.html (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Grid.js
r1721 r2091 108 108 this._initTiles(); 109 109 } else { 110 var buffer = (this.buffer) ? this.buffer*1.5 : 1; 110 111 while (true) { 111 112 var tlLayer = this.grid[0][0].position; 112 113 var tlViewPort = 113 114 this.map.getViewPortPxFromLayerPx(tlLayer); 114 if (tlViewPort.x > -this.tileSize.w * ( this.buffer - 1)) {115 if (tlViewPort.x > -this.tileSize.w * (buffer - 1)) { 115 116 this.shiftColumn(true); 116 } else if (tlViewPort.x < -this.tileSize.w * this.buffer) {117 } else if (tlViewPort.x < -this.tileSize.w * buffer) { 117 118 this.shiftColumn(false); 118 } else if (tlViewPort.y > -this.tileSize.h * ( this.buffer - 1)) {119 } else if (tlViewPort.y > -this.tileSize.h * (buffer - 1)) { 119 120 this.shiftRow(true); 120 } else if (tlViewPort.y < -this.tileSize.h * this.buffer) {121 } else if (tlViewPort.y < -this.tileSize.h * buffer) { 121 122 this.shiftRow(false); 122 123 } else { 123 124 break; 124 125 } 126 }; 127 if (this.buffer == 0) { 128 for (var r=0, rl=this.grid.length; r<rl; r++) { 129 var row = this.grid[r]; 130 for (var c=0, cl=row.length; c<cl; c++) { 131 var tile = row[c]; 132 if (!tile.drawn && tile.bounds.intersectsBounds(bounds, false)) { 133 tile.draw(); 134 } 135 } 136 } 125 137 } 126 138 } … … 154 166 */ 155 167 _initTiles:function() { 168 169 // work out mininum number of rows and columns; this is the number of 170 // tiles required to cover the viewport plus one for panning 156 171 var viewSize = this.map.getSize(); 172 var minRows = Math.ceil(viewSize.h/this.tileSize.h) + 1; 173 var minCols = Math.ceil(viewSize.w/this.tileSize.w) + 1; 174 157 175 var bounds = this.map.getExtent(); 158 176 var extent = this.map.getMaxExtent(); … … 217 235 tileoffsetlon += tilelon; 218 236 tileoffsetx += this.tileSize.w; 219 } while (tileoffsetlon <= bounds.right + tilelon * this.buffer) 220 237 } while ((tileoffsetlon <= bounds.right + tilelon * this.buffer) 238 || colidx < minCols) 239 221 240 tileoffsetlat -= tilelat; 222 241 tileoffsety += this.tileSize.h; 223 } while(tileoffsetlat >= bounds.bottom - tilelat * this.buffer) 224 242 } while((tileoffsetlat >= bounds.bottom - tilelat * this.buffer) 243 || rowidx < minRows) 244 245 // remove extra rows 246 while (this.grid.length > rowidx) { 247 var row = this.grid.pop(); 248 for (var i=0, l=row.length; i<l; i++) { 249 row[i].destroy(); 250 } 251 } 252 253 // remove extra columns 254 while (this.grid[0].length > colidx) { 255 for (var i=0, l=this.grid.length; i<l; i++) { 256 var row = this.grid[i]; 257 var tile = row.pop(); 258 tile.destroy(); 259 } 260 } 261 225 262 //now actually draw the tiles 226 263 this.spiralTileLoad(); … … 326 363 var row = this.grid[iRow]; 327 364 for(var iCol=0; iCol < row.length; iCol++) { 328 OpenLayers.Util.clearArray(row[iCol]);365 row[iCol].destroy(); 329 366 } 367 this.grid = []; 330 368 } 331 369 } trunk/openlayers/lib/OpenLayers/Tile.js
r2017 r2091 70 70 */ 71 71 draw:function() { 72 this.drawn = true; 72 this.clear(); 73 return ((this.layer.displayOutsideMaxExtent 74 || (this.layer.maxExtent 75 && this.bounds.intersectsBounds(this.layer.maxExtent, false))) 76 && !(this.layer.buffer == 0 77 && !this.bounds.intersectsBounds(this.layer.map.getExtent(), false))); 73 78 }, 74 79 trunk/openlayers/lib/OpenLayers/Tile/Image.js
r1721 r2091 44 44 */ 45 45 draw:function() { 46 OpenLayers.Tile.prototype.draw.apply(this, arguments); 47 46 if (this.layer != this.layer.map.baseLayer && this.layer.reproject) { 47 this.bounds = this.getBoundsFromBaseLayer(this.position); 48 } 49 if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) { 50 return false; 51 } 48 52 if (this.imgDiv == null) { 49 53 this.initImgDiv(); 50 54 } 51 if (this.layer != this.layer.map.baseLayer && this.layer.reproject) { 52 this.bounds = this.getBoundsFromBaseLayer(this.position); 55 56 this.url = this.layer.getURL(this.bounds); 57 58 if (this.layer.alpha) { 59 OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, 60 null, this.position, this.size, this.url); 61 } else { 62 this.imgDiv.src = this.url; 63 OpenLayers.Util.modifyDOMElement(this.imgDiv, 64 null, this.position, this.size) ; 53 65 } 54 55 this.url = this.layer.getURL(this.bounds); 56 this.imgDiv.style.display = "none"; 57 if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent && 58 (this.bounds.intersectsBounds(this.layer.maxExtent,false)) 59 )) { 60 if (this.layer.alpha) { 61 OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv, 62 null, this.position, this.size, this.url); 63 } else { 64 this.imgDiv.src = this.url; 65 OpenLayers.Util.modifyDOMElement(this.imgDiv, 66 null, this.position, this.size) ; 67 } 68 } 66 this.drawn = true; 67 return true; 69 68 }, 70 69 trunk/openlayers/lib/OpenLayers/Tile/WFS.js
r2029 r2091 58 58 */ 59 59 draw:function() { 60 if ( this.drawn) {61 this.clear();60 if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) { 61 return false; 62 62 } 63 OpenLayers.Tile.prototype.draw.apply(this, arguments); 64 if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent && 65 this.layer.maxExtent.intersectsBounds(this.bounds, false))) { 66 this.loadFeaturesForRegion(this.requestSuccess); 67 } 63 this.loadFeaturesForRegion(this.requestSuccess); 64 this.drawn = true; 65 return true; 68 66 }, 69 67 trunk/openlayers/tests/test_Tile_Image.html
r1908 r2091 74 74 tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size); 75 75 tile.draw() 76 t.eq(tile.imgDiv .src, "", "Images against side of maxextent don't load");76 t.eq(tile.imgDiv, null, "Images against side of maxextent don't load"); 77 77 tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-91,180,90), url, size); 78 78 tile.draw() … … 145 145 } 146 146 function test_04_Tile_Image_Display_After_Move(t) { 147 t.plan( 3);147 t.plan(2); 148 148 var position = new OpenLayers.Pixel(20,30); 149 149 var bounds = new OpenLayers.Bounds(1,2,3,4); … … 158 158 tile.draw(); 159 159 tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true); 160 t.delay_call( 1, function() { t.eq(tile.imgDiv .style.display, 'none', "Tile display is set to none.") } );160 t.delay_call( 1, function() { t.eq(tile.imgDiv, null, "Tile imgDiv is null.") } ); 161 161 var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 162 162 "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}, {'alpha':true}); … … 165 165 tile.draw(); 166 166 tile.moveTo(new OpenLayers.Bounds(-185,-90,-180,-80), new OpenLayers.Pixel(-180,-85), true) 167 t.ok(tile.imgDiv.firstChild.src != tile.url, "Check to make sure that the alpha image URL really is different"); 168 t.delay_call( 1, function() { t.eq(tile.imgDiv.style.display, 'none', "Alpha tile display is set to none.") } ); 167 t.delay_call( 1, function() { t.eq(tile.imgDiv, null, "Alpha tile imgDiv is null.") } ); 169 168 170 169 }
