Skip to content

Instantly share code, notes, and snippets.

@danielquisbert
Last active June 26, 2017 00:28
Show Gist options
  • Save danielquisbert/10010a06f51c00ae6c379b274662865c to your computer and use it in GitHub Desktop.
Save danielquisbert/10010a06f51c00ae6c379b274662865c to your computer and use it in GitHub Desktop.

Cambiar el nombre para mostrar de las secciones BaseLayer y Overlays del layerswitcher OL2

var map = (OpenLayers.Map ); // your map reference
var layerswitcher = (OpenLayers.Control.LayerSwitcher) // layer swicher control reference
OpenLayers.Lang[OpenLayers.Lang.getCode()]['Base Layer'] = "My base label";
OpenLayers.Lang[OpenLayers.Lang.getCode()]['Overlays'] = "My over label";
// remove current instance of layers switcher from map if attached.
map.removeControl( layerswitcher );
map.addControl( new OpenLayers.Control.LayerSwitcher( { /* options here */ } ) );

Adicionalmente, podría probarse también:

  layerSwitcher = map.getControlsByClass("OpenLayers.Control.LayerSwitcher")[0];

  layerSwitcher.baseLbl.innerText // (returns "Base Layer")
  layerSwitcher.dataLbl.innerText // (returns "Overlays")

// asignando nuevo texto

  layerSwitcher.baseLbl.innerText = "YOUR NEW TEXT"
  layerSwitcher.dataLbl.innerText = "YOUR NEW OVERLAY TEXT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment