[OpenLayers-Users] LayerSwitcher - current base map

bradleyspencer brad at cubewerx.com.au
Wed Jun 13 19:36:53 EDT 2007


Christopher,

Thanks for that it works a treat.
For what its worth, I have added my full event handler here so others know
how to do this if they need to.

map.events.register('changebaselayer', null, function(evt)
{
// check to see what base layer has been selected from layerSwithcher
control
if (this.baseLayer.name  ==  "your base layer name")
	{
		// activate the DIV with the TP Credit icon
var TPCredit = document.getElementById("poweredByTerraPages")
		TPCredit.style.display='block';
	}
	else
	{
		// deactivate the DIV with the TP Credit icon
var TPCredit = document.getElementById("poweredByTerraPages")
		TPCredit.style.display='none';
	}
	Event.stop(evt);
});

Cheers,

Brad Spencer
http://www.cubewerx.com.au

-----Original Message-----
From: Christopher Schmidt [mailto:crschmidt at metacarta.com]
Sent: Thursday, 14 June 2007 12:42 AM
To: bradleyspencer
Cc: openlayers users
Subject: Re: [OpenLayers-Users] LayerSwitcher - current base map

On Wed, Jun 13, 2007 at 07:09:32PM +1000, bradleyspencer wrote:
> List,
>
> I need to know which map is selected as the current base map from those
> available in layerSwitcher so that I can add a watermark to the map.
>
> Is there anyway to place an event on layerSwitcher that can tell me which
> layer has been interactively selected?

As defined in the Map object:

    EVENT_TYPES: [
        "addlayer", "removelayer", "changelayer", "movestart", "move",
        "moveend", "zoomend", "popupopen", "popupclose",
        "addmarker", "removemarker", "clearmarkers", "mouseover",
        "mouseout", "mousemove", "dragstart", "drag", "dragend",
        "changebaselayer"],

One of those will probably help you get what you want.

Regards,
--
Christopher Schmidt
MetaCarta




More information about the Users mailing list