allow layers to prevent themselves from displaying in the layer switcher via the 'displayInLayerSwitcher' boolean option. modify example.html to show usage

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1528 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-10-02 23:24:02 +00:00
parent 41f619b05e
commit 36a76054a4
3 changed files with 51 additions and 43 deletions

View File

@@ -24,7 +24,8 @@
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
"prov_bound,fedlimit,rail,road,popplace",
transparent: "true", format: "image/png" });
transparent: "true", format: "image/png" },
{ displayInLayerSwitcher: false });
map.addLayers([ol_wms, jpl_wms, dm_wms]);
map.addControl(new OpenLayers.Control.LayerSwitcher());

View File

@@ -103,6 +103,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
var layer = this.map.layers[i];
var baseLayer = layer.isBaseLayer;
if (baseLayer || layer.displayInLayerSwitcher) {
if (!baseLayer) {
containsOverlays = true;
}
@@ -145,7 +147,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
groupDiv.appendChild(inputElem);
groupDiv.appendChild(labelSpan);
groupDiv.appendChild(br);
}
}
// if no overlays, dont display the overlay label

View File

@@ -36,6 +36,11 @@ OpenLayers.Layer.prototype = {
* @type boolean */
alpha: false,
/** should the layer's name appear in the layer switcher?
*
* @type boolean */
displayInLayerSwitcher: true,
// OPTIONS
/** @type Array */