[OpenLayers-Users] Layer on/off

Linda Rawson linda.rawson at gmail.com
Thu Sep 13 19:05:10 EDT 2007


I don't know if this will help you or not either but here is what I do.  I
have a layer that is identified as dm_wms.


map.events.register('moveend', map, function (e) {

    myScale = (map.getMaxResolution() / map.getResolution());

    if (myScale >= 1024) {

        dm_wms.setVisibility(true);

    } else {

        dm_wms.setVisibility(false);

    }

}
Linda Rawson


On 9/13/07, bradleyspencer <brad at cubewerx.com.au> wrote:
>
> 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
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070913/8989543d/attachment.html


More information about the Users mailing list