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:
@@ -24,7 +24,8 @@
|
|||||||
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
|
"http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
|
||||||
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
|
{layers: "bathymetry,land_fn,park,drain_fn,drainage," +
|
||||||
"prov_bound,fedlimit,rail,road,popplace",
|
"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.addLayers([ol_wms, jpl_wms, dm_wms]);
|
||||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
var layer = this.map.layers[i];
|
var layer = this.map.layers[i];
|
||||||
var baseLayer = layer.isBaseLayer;
|
var baseLayer = layer.isBaseLayer;
|
||||||
|
|
||||||
|
if (baseLayer || layer.displayInLayerSwitcher) {
|
||||||
|
|
||||||
if (!baseLayer) {
|
if (!baseLayer) {
|
||||||
containsOverlays = true;
|
containsOverlays = true;
|
||||||
}
|
}
|
||||||
@@ -145,7 +147,7 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
groupDiv.appendChild(inputElem);
|
groupDiv.appendChild(inputElem);
|
||||||
groupDiv.appendChild(labelSpan);
|
groupDiv.appendChild(labelSpan);
|
||||||
groupDiv.appendChild(br);
|
groupDiv.appendChild(br);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if no overlays, dont display the overlay label
|
// if no overlays, dont display the overlay label
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ OpenLayers.Layer.prototype = {
|
|||||||
* @type boolean */
|
* @type boolean */
|
||||||
alpha: false,
|
alpha: false,
|
||||||
|
|
||||||
|
/** should the layer's name appear in the layer switcher?
|
||||||
|
*
|
||||||
|
* @type boolean */
|
||||||
|
displayInLayerSwitcher: true,
|
||||||
|
|
||||||
// OPTIONS
|
// OPTIONS
|
||||||
|
|
||||||
/** @type Array */
|
/** @type Array */
|
||||||
|
|||||||
Reference in New Issue
Block a user