Changeset 1539
- Timestamp:
- 10/03/06 08:37:25 (2 years ago)
- Files:
-
- trunk/openlayers/doc/Control.LayerSwitcher.txt (modified) (1 diff)
- trunk/openlayers/examples/controls.html (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js (modified) (5 diffs)
- trunk/openlayers/tests/test_Control_LayerSwitcher.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/doc/Control.LayerSwitcher.txt
r1424 r1539 12 12 position -- (inherited from {OpenLayers.Control}) {OpenLayers.Pixel} to use as the top-left corner of the control div, relative to the map area. 13 13 activeColor -- The color to use for the background of the layer switcher div. 14 14 ascending -- Ascending determines whether layers are added to the layer switcher in ascending or descending order. If ascending is true, the lowest layer is appended to the list first. If ascending is false, the lowest layer is at the very bottom of the LayerSwitcher. Default is true. trunk/openlayers/examples/controls.html
r1424 r1539 14 14 var map = new OpenLayers.Map('map', { controls: [] }); 15 15 16 map.addControl(new OpenLayers.Control.PanZoomBar()); 17 map.addControl(new OpenLayers.Control.MouseToolbar()); 18 map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false})); 19 map.addControl(new OpenLayers.Control.Permalink()); 20 map.addControl(new OpenLayers.Control.Permalink($('permalink'))); 16 21 var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 17 22 "http://labs.metacarta.com/wms/vmap0", … … 32 37 33 38 map.addLayers([ol_wms, jpl_wms, dm_wms]); 34 map.addControl(new OpenLayers.Control.PanZoomBar());35 map.addControl(new OpenLayers.Control.MouseToolbar());36 map.addControl(new OpenLayers.Control.LayerSwitcher());37 map.addControl(new OpenLayers.Control.Permalink());38 map.addControl(new OpenLayers.Control.Permalink($('permalink')));39 39 if (!map.getCenter()) map.zoomToMaxExtent(); 40 40 } trunk/openlayers/lib/OpenLayers/Control/LayerSwitcher.js
r1528 r1539 44 44 maximizeDiv: null, 45 45 46 /** @type Boolean */ 47 ascending: true, 48 46 49 /** 47 50 * @constructor … … 100 103 var containsOverlays = false; 101 104 102 for( var i = 0; i < this.map.layers.length; i++) { 103 var layer = this.map.layers[i]; 105 var layers = this.map.layers.slice(); 106 if (!this.ascending) { layers.reverse(); } 107 for( var i = 0; i < layers.length; i++) { 108 var layer = layers[i]; 104 109 var baseLayer = layer.isBaseLayer; 105 110 … … 310 315 baseLbl.style.marginLeft = "3px"; 311 316 baseLbl.style.marginBottom = "3px"; 312 this.layersDiv.appendChild(baseLbl);313 317 314 318 this.baseLayersDiv = document.createElement("div"); … … 317 321 this.onLayerClick.bindAsEventListener(this)); 318 322 */ 319 this.layersDiv.appendChild(this.baseLayersDiv);320 323 321 324 … … 325 328 this.dataLbl.style.marginLeft = "3px"; 326 329 this.dataLbl.style.marginBottom = "3px"; 327 this.layersDiv.appendChild(this.dataLbl);328 330 329 331 this.dataLayersDiv = document.createElement("div"); 330 332 this.dataLayersDiv.style.paddingLeft = "10px"; 331 /*Event.observe(this.dataLayersDiv, "click", 332 this.onLayerClick.bindAsEventListener(this)); 333 */ 334 this.layersDiv.appendChild(this.dataLayersDiv); 335 333 334 if (this.ascending) { 335 this.layersDiv.appendChild(baseLbl); 336 this.layersDiv.appendChild(this.baseLayersDiv); 337 this.layersDiv.appendChild(this.dataLbl); 338 this.layersDiv.appendChild(this.dataLayersDiv); 339 } else { 340 this.layersDiv.appendChild(this.dataLbl); 341 this.layersDiv.appendChild(this.dataLayersDiv); 342 this.layersDiv.appendChild(baseLbl); 343 this.layersDiv.appendChild(this.baseLayersDiv); 344 } 345 336 346 this.div.appendChild(this.layersDiv); 337 347 trunk/openlayers/tests/test_Control_LayerSwitcher.html
r1424 r1539 82 82 83 83 } 84 function test_05_Control_LayerSwitcher_ascendingw (t) { 85 86 t.plan( 4 ); 87 88 map = new OpenLayers.Map('map'); 89 var layer = new OpenLayers.Layer.WMS("WMS", 90 "http://octo.metacarta.com/cgi-bin/mapserv?", 91 {map: "/mapdata/vmap_wms.map", layers: "basic"}); 92 map.addLayer(layer); 93 94 markers = new OpenLayers.Layer.Markers("markers"); 95 map.addLayer(markers); 96 97 control = new OpenLayers.Control.LayerSwitcher(); 98 map.addControl(control); 99 control2 = new OpenLayers.Control.LayerSwitcher({'ascending':false}); 100 map.addControl(control2); 101 t.eq(control.div.childNodes[1].childNodes[0].innerHTML, "<u>Base Layer</u>", "Base Layers first in LayerSwitcher with ascending true"); 102 t.eq(control.div.childNodes[1].childNodes[2].innerHTML, "<u>Overlays</u>", "Overlays in LayerSwitcher with ascending true"); 103 t.eq(control2.div.childNodes[1].childNodes[2].innerHTML, "<u>Base Layer</u>", "Base Layers last in LayerSwitcher with ascending false"); 104 t.eq(control2.div.childNodes[1].childNodes[0].innerHTML, "<u>Overlays</u>", "Base Layers last in LayerSwitcher with ascending false"); 105 } 84 106 85 107
