Ticket #937: patch-937-r5542-B0.diff
| File patch-937-r5542-B0.diff, 4.8 kB (added by elemoine, 1 year ago) |
|---|
-
lib/OpenLayers/Map.js
old new 1308 1308 for (var i = 0; i < this.layers.length; i++) { 1309 1309 var layer = this.layers[i]; 1310 1310 if (!layer.isBaseLayer) { 1311 1312 var moveLayer; 1313 var inRange = layer.calculateInRange(); 1314 if (layer.inRange != inRange) { 1315 // Layer property has changed. We are going 1316 // to call moveLayer so that the layer can be turned 1317 // off or on. 1318 layer.inRange = inRange; 1319 moveLayer = true; 1320 this.events.triggerEvent("changelayer"); 1321 } else { 1322 // If nothing has changed, then we only move the layer 1323 // if it is visible and inrange. 1324 moveLayer = (layer.visibility && layer.inRange); 1325 } 1326 1327 if (moveLayer) { 1311 // we only move the layer if it is visible and inrange. 1312 if (layer.calculateInRange() && layer.visibility) { 1328 1313 layer.moveTo(bounds, zoomChanged, dragging); 1329 1314 } 1330 1315 } -
lib/OpenLayers/Layer.js
old new 369 369 if (this.map) { 370 370 371 371 // min/max Range may have changed 372 this.inRange = this.calculateInRange();372 var inRange = this.calculateInRange(); 373 373 374 374 // map's center might not yet be set 375 375 var extent = this.getExtent(); 376 376 377 if (extent && this.inRange && this.visibility) {377 if (extent && inRange && this.visibility) { 378 378 this.moveTo(extent, true, false); 379 379 redrawn = true; 380 380 } … … 392 392 * dragging - {Boolean} 393 393 */ 394 394 moveTo:function(bounds, zoomChanged, dragging) { 395 var display = this.visibility; 396 if (!this.isBaseLayer) { 397 display = display && this.inRange; 398 } 399 this.display(display); 395 //to be overridden by subclasses 400 396 }, 401 397 402 398 /** … … 433 429 this.initResolutions(); 434 430 435 431 if (!this.isBaseLayer) { 436 this.inRange = this.calculateInRange();437 var show = ( (this.visibility) && (this.inRange));432 var inRange = this.calculateInRange(); 433 var show = (this.visibility && inRange); 438 434 this.div.style.display = show ? "" : "none"; 439 435 } 440 436 … … 549 545 550 546 /** 551 547 * Method: calculateInRange 548 * Checks if layer is layer minResolution and maxResolution matches the 549 * current map resolution, and sets inRange property. If inRange 550 * value changes, also triggers the changelayer map event and 551 * shows/hides the layer. 552 552 * 553 553 * Returns: 554 554 * {Boolean} The layer is displayable at the current map's current 555 555 * resolution. 556 556 */ 557 557 calculateInRange: function() { 558 var inRange = false;558 var inRange; 559 559 if (this.map) { 560 560 var resolution = this.map.getResolution(); 561 inRange = ( (resolution >= this.minResolution) && 562 (resolution <= this.maxResolution) ); 561 inRange = (resolution >= this.minResolution) && 562 (resolution <= this.maxResolution); 563 } else { 564 inRange = false; 563 565 } 566 // if inRange value changes, trigger changerlayer event, 567 // and show/hide the layer (ie. change div element display) 568 // also change the inRange property 569 if (this.inRange != inRange) { 570 this.inRange = inRange; 571 this.map.events.triggerEvent("changelayer"); 572 this.display(inRange); 573 } 564 574 return inRange; 565 575 }, 566 576 -
lib/OpenLayers/Layer/WFS.js
old new 209 209 var outOfBounds = (!firstRendering && 210 210 !this.tile.bounds.containsBounds(bounds)); 211 211 212 if ( (zoomChanged || firstRendering || (!dragging && outOfBounds)) 213 && this.inRange) { 212 if (zoomChanged || firstRendering || (!dragging && outOfBounds)) { 214 213 //determine new tile bounds 215 214 var center = bounds.getCenterLonLat(); 216 215 var tileWidth = bounds.getWidth() * this.ratio;
