Hello OpenLayers,

I've been at this all day long and honestly I'm out of ideas.  I have some
WMS layers that I would like to display/not display depending on the current
zoom level.  Yes, I have went through the API docs and they seem to be clear
as day, but I follow everything that is suggested and I'm not getting the
results desired :(

These were some of the sources that I looked at:
http://trac.osgeo.org/openlayers/wiki/SettingZoomLevels
http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.maxExtent

Then to make matters even worse I found out that if you have an Open Street
Map base layer displaying on load it seems to limit your control over the
map's numZoomLevels, just what I needed, since I DO want to use this as my
loading base layer...

http://osgeo-org.1803224.n2.nabble.com/Can-t-restrict-Openlayers-Layer-OSM-to-use-specific-zoom-levels-td5265038.html

So my questions are:

What am I doing wrong?
Is it true that there really is no workaround on the control of zoom levels
when using an Open Street Map base layer on load?  Or is there something I
just don't know?

Here are some of my code attempts: 
Take 1:  tib_villages layer should only show when the zoom level is 8-10,
doesn't work!

var options = {
                                        controls: [new 
OpenLayers.Control.Navigation()], //Needed to use GeoExt
controls such as the zoomslider
                        maxExtent: new OpenLayers.Bounds(-20037508.34, 
-20037508.34,
20037508.34, 20037508.34),
                        units: 'm',
                        numZoomLevels: null, //setting the map's zoom levels to 
null
                        allOverlays: false
                }

var osm = new OpenLayers.Layer.OSM(); //MY base layer

//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
                                "Villages", 
"http://localhost:8080/geoserver/wms";,
{layers: 'cite:tib_villages', transparent: true, numZoomLevels: 10,
minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true,
visibility: true} 
                        );


Take 2:  tib_villages layer should only show when the zoom level is 8-10,
map should only have 10 zoom levels, but instead has 19 as the Open Street
Map Layer enforces it to,  doesn't work!

var options = {
                                        controls: [new 
OpenLayers.Control.Navigation()], //Needed to use GeoExt
controls such as the zoomslider
                        maxExtent: new OpenLayers.Bounds(-20037508.34, 
-20037508.34,
20037508.34, 20037508.34),
                        units: 'm',
                        numZoomLevels: 10, //setting the map's zoom levels to 
10 only
                        allOverlays: false
                }

var osm = new OpenLayers.Layer.OSM(); //MY base layer

//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
                                "Villages", 
"http://localhost:8080/geoserver/wms";,
{layers: 'cite:tib_villages', transparent: true, numZoomLevels: null,
minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true,
visibility: true} 
                        );

Take 3:  After getting rid of the Open Street Map base layer on load, the
map only has 10 zoom levels as specified, but tib_villages layer should only
show when the zoom level is 8-10, doesn't work!

var options = {
                                        controls: [new 
OpenLayers.Control.Navigation()], //Needed to use GeoExt
controls such as the zoomslider
                        maxExtent: new OpenLayers.Bounds(-20037508.34, 
-20037508.34,
20037508.34, 20037508.34),
                        units: 'm',
                        numZoomLevels: 10, //setting the map's zoom levels to 10
                        allOverlays: false
                }

//MY overlay layer
var tib_villages = new OpenLayers.Layer.WMS(
                                "Villages", 
"http://localhost:8080/geoserver/wms";,
{layers: 'cite:tib_villages', transparent: true, numZoomLevels: 10,
minZoomLevel: 8}, {isBaseLayer: false, displayInLayerSwitcher: true,
visibility: true} 
                        );

All of your suggestions are sincerely appreciated!

elshae
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Display-WMS-Layer-Based-on-Zoom-Level-tp5664040p5664040.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to