[OpenLayers-Users] Layer on/off

bradleyspencer brad at cubewerx.com.au
Thu Sep 13 18:43:18 EDT 2007


Prasad,

I'm not sure if this will help as I do not use the resolutions that much
(probably should?).

Anyway, I set up an event that is triggered every time there is a zoom
change. Then I can check the new zoom level and if the layer should be
displayed at that layer I do something like turning it on or off. Of course
it requires me to have arrays of display level thresholds for each layer -
this I do in an application config file at load time.

See http://www.ozdemo.org as a working example. Hope this can help you.

map.events.register('zoomend', null, function(evt)
	{
		var macroCheckBox = document.getElementById('macro');
		zmlevel= map.getZoom();
		// run through the layer controls array setting Checkbox to deactive
		for (j=0; j<numLayers; j++)
		{
			var layId= 'layer'+j;
			var layerCheckbox = document.getElementById(layId)

			// if the layer is viewable at this layer set the checkbox to reflect
			if (zmlevel < Minzm[j] || zmlevel > Maxzm[j])
			{	layerCheckbox.disabled = true;
				layerCheckbox.checked=false;
				layerVisibility(layId);
			}
			else
			{	layerCheckbox.disabled = false;
				if (macroCheckBox.checked)
				{
					layerCheckbox.checked= true;
					layerVisibility(layId);
				}

			}
		}
		Event.stop(evt);
    });

Cheers,

Brad Spencer
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]On
Behalf Of Christopher Schmidt
Sent: Thursday, 13 September 2007 10:47 PM
To: Prasad Choudhary
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] Layer on/off

On Thu, Sep 13, 2007 at 04:26:52AM -0700, Prasad Choudhary wrote:
>
> Hi again,
>
> I tried as you suggest,  as
>
> which is @ http://prasad.choudhary.googlepages.com/markers.html
> but still, not happening, is there some thing i missed out? please correct
> me.

The minResolution of the markers layer is not respecting the value you
passed in. I can't see why this is at the moment, but it seems to be a
bug. When I get time, I'll look into it -- for now, something like this
will work:

  var markers = new OpenLayers.Layer.Markers(
     "Markers",{'minResolution': 0.3515625, 'maxResolution': 1.40625} );
  map.addLayer(markers);
  markers.minResolution = .35;

Regards,
--
Christopher Schmidt
MetaCarta
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




More information about the Users mailing list