[OpenLayers-Users] Layer on/off

Prasad Choudhary prasad.choudhary at gmail.com
Thu Sep 13 07:26:52 EDT 2007


Hi again,

I tried as you suggest,  as 
<code>
var map, layer;

        function init(){
            
            map = new OpenLayers.Map( 'map', {
               controls: [new OpenLayers.Control.Navigation(),
                          new OpenLayers.Control.PanZoomBar(),
                          new OpenLayers.Control.LayerSwitcher(),
                          new OpenLayers.Control.MousePosition()],
						resolutions: new
Array(1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125,0.02197265625),
               			units: 'meters'} );
						
            layer = new OpenLayers.Layer.WMS( "OpenLayers
WMS","http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
                
            map.addLayer(layer);
            

           
            var markers = new OpenLayers.Layer.Markers(
"Markers",{'minResolution': 0.3515625, 'maxResolution': 1.40625} );
            map.addLayer(markers);
			
			map.setCenter(new OpenLayers.LonLat(0, 0), 0);
			
            
            markers.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(0,0)));
			
			map.events.register("click", map, function(e) {
alert(map.getResolution()); });
            
        }
</code>

which is @ http://prasad.choudhary.googlepages.com/markers.html
but still, not happening, is there some thing i missed out? please correct
me.

Thanks
Prasad


Christopher Schmidt-4 wrote:
> 
> On Thu, Sep 13, 2007 at 03:00:22AM -0700, Prasad Choudhary wrote:
>> 
>> Hello all,
>> 
>> Can any one tell me, way to on/off overlay(say marker or vector layer) 
>> for
>> certain zoom levels??
>> i was trying for
>> 
>> var markers = new OpenLayers.Layer.Markers( "Markers",{'minResolution':
>> 0.02, 'maxResolution': 0.02} ); but unfortunately that was not working.
> 
> Something like that should work, though setting them both to the exact
> same thing might be confusing it. try setting the minResolution to .0002
> instead or something, just to see if it works? When you're outside the
> resolution, the layer should be grayed out in the switcher.
> 
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://www.nabble.com/Layer-on-off-tf4434757.html#a12653008
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list