Changeset 1577
- Timestamp:
- 10/05/06 00:20:16 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (3 diffs)
- trunk/openlayers/lib/OpenLayers/Layer.js (modified) (5 diffs)
- trunk/openlayers/lib/OpenLayers/Layer/Canvas.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Google.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Grid.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Markers.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/MultiMap.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Map.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js
r1539 r1577 130 130 inputElem.layer = layer; 131 131 inputElem.control = this; 132 if (!layer.inRange()) { 133 inputElem.disabled = true; 134 } 132 135 Event.observe(inputElem, "mouseup", 133 136 this.onInputClick.bindAsEventListener(inputElem)); … … 135 138 // create span 136 139 var labelSpan = document.createElement("span"); 140 if (!layer.inRange()) { 141 labelSpan.style.color = "grey"; 142 } 137 143 labelSpan.innerHTML = layer.name; 138 144 labelSpan.style.verticalAlign = (baseLayer) ? "bottom" : "baseline"; … … 170 176 171 177 onInputClick: function(e) { 172 if (this.type == "radio") { 173 this.checked = true; 174 this.layer.map.setBaseLayer(this.layer, true); 175 this.layer.map.events.triggerEvent("changebaselayer"); 176 } else { 177 this.checked = !this.checked; 178 this.control.updateMap(); 178 if (!this.disabled) { 179 if (this.type == "radio") { 180 this.checked = true; 181 this.layer.map.setBaseLayer(this.layer, true); 182 this.layer.map.events.triggerEvent("changebaselayer"); 183 } else { 184 this.checked = !this.checked; 185 this.control.updateMap(); 186 } 179 187 } 180 188 Event.stop(e); trunk/openlayers/lib/OpenLayers/Layer.js
r1576 r1577 41 41 * @type boolean */ 42 42 displayInLayerSwitcher: true, 43 44 /** Whether or not the layer should be displayed in the map 45 * 46 * @type Boolean 47 */ 48 visibility: true, 43 49 44 50 // OPTIONS … … 181 187 */ 182 188 moveTo:function(bounds, zoomChanged, dragging) { 183 //this function can be implemented by subclasses. 189 if (zoomChanged) { 190 this.display(this.visibility && this.inRange()); 191 this.map.events.triggerEvent("changelayer"); 192 } 184 193 }, 185 194 … … 212 221 } 213 222 } 214 if (this.isBaseLayer) { 215 this.initResolutions(); 216 } 223 this.initResolutions(); 217 224 }, 218 225 219 226 /** 220 * @returns Whether or not the layer is visible227 * @returns Whether or not the layer should be displayed (if in range) 221 228 * @type Boolean 222 229 */ 223 230 getVisibility: function() { 224 return (this.div.style.display != "none");231 return this.visibility; 225 232 }, 226 233 227 234 /** 228 * @param {Boolean} visible 235 * @param {Boolean} visible Whether or not to display the layer 236 * (if in range) 229 237 * @param {Boolean} noEvent 230 238 */ 231 setVisibility: function(visib le, noEvent) {232 if (visib le != this.getVisibility()) {233 this. div.style.display = (visible) ? "block" : "none";234 if ( (visible) && (this.map != null)) {239 setVisibility: function(visibility, noEvent) { 240 if (visibility != this.visibility) { 241 this.visibility = visibility; 242 if (this.map != null) { 235 243 var extent = this.map.getExtent(); 236 244 if (extent != null) { … … 244 252 } 245 253 }, 246 254 255 /** 256 * @param {Boolean} display 257 */ 258 display: function(display) { 259 if (display != (this.div.style.display != "none")) { 260 this.div.style.display = (display) ? "block" : "none"; 261 } 262 }, 263 264 /** 265 * @returns Whether or not the layer is displayable at the current map's 266 * current resolution 267 * @type Boolean 268 */ 269 inRange: function() { 270 var inRange = false; 271 if (this.map) { 272 var resolution = this.map.getResolution(); 273 inRange = ( (resolution >= this.minResolution) && 274 (resolution <= this.maxResolution) ); 275 } 276 return inRange; 277 }, 278 247 279 /** 248 280 * @param {Boolean} isBaseLayer … … 335 367 return(b-a); 336 368 }); 369 370 this.minResolution = this.resolutions[this.resolutions.length - 1]; 371 this.maxResolution = this.resolutions[0]; 372 373 this.minScale = 374 OpenLayers.Util.getScaleFromResolution(this.maxResolution, 375 this.units); 376 this.maxScale = 377 OpenLayers.Util.getScaleFromResolution(this.minResolution, 378 this.units); 337 379 }, 338 380 trunk/openlayers/lib/OpenLayers/Layer/Canvas.js
r1538 r1577 50 50 */ 51 51 moveTo:function(bounds, zoomChanged, dragging) { 52 this.redraw(); 52 OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 53 54 this.redraw(); 53 55 }, 54 56 trunk/openlayers/lib/OpenLayers/Layer/Google.js
r1538 r1577 77 77 */ 78 78 moveTo:function(bounds, zoomChanged, dragging) { 79 OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments); 79 80 80 81 if ((this.gmap != null) && (!this.dragging)) { trunk/openlayers/lib/OpenLayers/Layer/Grid.js
r1437 r1577 97 97 */ 98 98 moveTo:function(bounds, zoomChanged, dragging) { 99 OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments); 100 99 101 if (bounds == null) { 100 102 bounds = this.map.getExtent(); trunk/openlayers/lib/OpenLayers/Layer/Markers.js
r1538 r1577 49 49 */ 50 50 moveTo:function(bounds, zoomChanged, dragging) { 51 OpenLayers.Layer.prototype.moveTo.apply(this, arguments); 52 51 53 if (zoomChanged) { 52 54 this.redraw(); trunk/openlayers/lib/OpenLayers/Layer/MultiMap.js
r1538 r1577 48 48 */ 49 49 moveTo:function(bounds, zoomChanged, dragging) { 50 OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments); 50 51 51 52 if (this.multimap != null) { trunk/openlayers/lib/OpenLayers/Layer/VirtualEarth.js
r1538 r1577 51 51 */ 52 52 moveTo:function(bounds, zoomChanged, dragging) { 53 OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments); 53 54 54 55 if (this.vemap != null) { trunk/openlayers/lib/OpenLayers/Layer/Yahoo.js
r1538 r1577 48 48 */ 49 49 moveTo:function(bounds, zoomChanged, dragging) { 50 OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments); 50 51 51 52 if (this.yahoomap != null) { trunk/openlayers/lib/OpenLayers/Map.js
r1538 r1577 621 621 for (var i = 0; i < this.layers.length; i++) { 622 622 var layer = this.layers[i]; 623 if ( layer.getVisibility()) {623 if (zoomChanged || (layer.display && layer.inRange())) { 624 624 layer.moveTo(bounds, zoomChanged, dragging); 625 625 }
