Ticket #795: redraw.4.patch
| File redraw.4.patch, 6.2 kB (added by tschaub, 1 year ago) |
|---|
-
tests/test_Layer.html
old new 165 165 166 166 } 167 167 168 function test_Layer_redraw(t) { 169 t.plan(8) 170 171 var name = 'Test Layer'; 172 var url = "http://octo.metacarta.com/cgi-bin/mapserv"; 173 var params = { map: '/mapdata/vmap_wms.map', 174 layers: 'basic', 175 format: 'image/jpeg'}; 176 177 var layer = new OpenLayers.Layer.WMS(name, url, params); 178 179 t.ok(!layer.redraw(), 180 "redraw on an orphan layer returns false"); 181 182 var map = new OpenLayers.Map('map'); 183 map.addLayer(layer); 184 185 t.ok(!layer.redraw(), 186 "redraw returns false if map does not yet have a center"); 187 map.zoomToMaxExtent(); 188 189 t.ok(layer.redraw(), 190 "redraw returns true after map has a center"); 191 192 layer.setVisibility(false); 193 t.ok(!layer.redraw(), 194 "redraw returns false if a layer is not visible"); 195 196 layer.setVisibility(true); 197 t.ok(layer.redraw(), 198 "redraw returns true even if extent has not changed"); 199 200 layer.moveTo = function(bounds, zoomChanged, dragging) { 201 var extent = layer.map.getExtent(); 202 t.ok(bounds.equals(extent), 203 "redraw calls moveTo with the map extent"); 204 t.ok(zoomChanged, 205 "redraw calls moveTo with zoomChanged true"); 206 t.ok(!dragging, 207 "redraw calls moveTo with dragging false"); 208 } 209 layer.redraw(); 210 211 } 168 212 169 213 /****** 170 214 * -
lib/OpenLayers/Layer.js
old new 335 335 }, 336 336 337 337 /** 338 * APIMethod: redraw 339 * Redraws the layer. Returns true if the layer was redrawn, false if not. 340 * 341 * Return: 342 * {Boolean} The layer was redrawn. 343 */ 344 redraw: function() { 345 var redrawn = false; 346 if (this.map) { 347 348 // min/max Range may have changed 349 this.inRange = this.calculateInRange(); 350 351 // map's center might not yet be set 352 var extent = this.getExtent(); 353 354 if (extent && this.inRange && this.visibility) { 355 this.moveTo(extent, true, false); 356 redrawn = true; 357 } 358 } 359 return redrawn; 360 }, 361 362 /** 338 363 * Method: moveTo 339 364 * 340 365 * Parameters: … … 451 476 if (visibility != this.visibility) { 452 477 this.visibility = visibility; 453 478 this.display(visibility); 454 if (visibility && this.map != null) { 455 var extent = this.map.getExtent(); 456 if (extent != null) { 457 this.moveTo(extent, true); 458 } 459 } 479 this.redraw(); 460 480 if ((this.map != null) && 461 481 ((noEvent == null) || (noEvent == false))) { 462 482 this.map.events.triggerEvent("changelayer"); -
lib/OpenLayers/Map.js
old new 518 518 layer.setVisibility(false); 519 519 } 520 520 } else { 521 if (this.getCenter() != null) { 522 layer.moveTo(this.getExtent(), true); 523 } 521 layer.redraw(); 524 522 } 525 523 526 524 this.events.triggerEvent("addlayer"); -
lib/OpenLayers/Layer/Markers.js
old new 72 72 OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 73 73 74 74 if (zoomChanged || !this.drawn) { 75 this.redraw(); 75 for(i=0; i < this.markers.length; i++) { 76 this.drawMarker(this.markers[i]); 77 } 76 78 this.drawn = true; 77 79 } 78 80 }, … … 116 118 } 117 119 }, 118 120 119 /**120 * APIMethod: redraw121 * Clear all the marker div's from the layer and then redraw all of them.122 * Use the map to recalculate new placement of markers.123 */124 redraw: function() {125 for(i=0; i < this.markers.length; i++) {126 this.drawMarker(this.markers[i]);127 }128 },129 130 121 /** 131 122 * Method: drawMarker 132 123 * Calculate the pixel location for the marker, create it, and -
lib/OpenLayers/Layer/MapServer/Untiled.js
old new 241 241 */ 242 242 setUrl: function(newUrl) { 243 243 OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments); 244 this. moveTo();244 this.redraw(); 245 245 }, 246 246 247 247 /** … … 254 254 mergeNewParams:function(newParams) { 255 255 OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, 256 256 [newParams]); 257 //redraw 258 this.moveTo(null, true); 257 this.redraw(); 259 258 }, 260 259 261 260 /** -
lib/OpenLayers/Layer/WMS/Untiled.js
old new 257 257 */ 258 258 setUrl: function(newUrl) { 259 259 OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments); 260 this. moveTo();260 this.redraw(); 261 261 }, 262 262 263 263 /** … … 272 272 var newArguments = [upperParams]; 273 273 OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this, 274 274 newArguments); 275 //redraw 276 this.moveTo(null, true); 275 this.redraw(); 277 276 }, 278 277 279 278 /**
