[OpenLayers-Users] Display WMS layer depending on ZoomLevel

Paul Curran paulcurran9 at googlemail.com
Thu Oct 29 07:14:53 EDT 2009


Thanks for the response.

My layers are currently set to ON but as i have mentioned this results in my
layers not being displayed (WMSLoadGetMapParams():WMS server error is shown
repeatedly within the OL map window). If layer is DEFAULT it is shown fine
but i then cannot hide the layer. My map looks as follows:

MAP

  NAME UK1
 PROJECTION
    'proj=longlat'
    'ellps=WGS84'
    'datum=WGS84'
    'no_defs'
    ''
    END
    SIZE 1600 1200
    IMAGECOLOR  -1 -1 -1
    IMAGETYPE JPEG
    SHAPEPATH "http://localhost/openlayers/data/"
    #QGIS
    #EXTENT  -837824 -111116 1677552 1232884
    #Port Talbot
    #EXTENT 272000 187000 278000 193000
    #UK
    EXTENT  0 0 660046 1240000
    UNITS METERS


 WEB
   TEMPLATE "http://localhost/openlayers/examples/zoomlevelsuktest2.html"
   LOG "\ms4w\tmp\ms_tmp\log.txt"
      IMAGEPATH "\ms4w\tmp\ms_tmp\"
      IMAGEURL "/ms_tmp/"
      METADATA
  'wms_title' "map"
        'wms_onlineresource'  "http://127.0.0.1./cgi-bin/mapserv?map=uk2.map
"
      END
 END
  LAYER

    NAME "UK250"
    METADATA
      'wms_title' "wms_demo"
    END
    STATUS ON
    TYPE raster
    TILEINDEX "250K"
    TILEITEM "Location"
    PROJECTION
  'proj=longlat'
  'ellps=WGS84'
  'datum=WGS84'
  'no_defs'
  ''
    END
    CLASS
      STYLE
       COLOR 0 0 0
      END
      LABEL
       COLOR 0 0 0
       SIZE SMALL
      END

    END

  END

  LAYER

    NAME "UK"
    METADATA
      'wms_title' "wms_demo"
    END
    STATUS ON
    TYPE raster
    TILEINDEX "map"
    TILEITEM "Location"
    PROJECTION
  'proj=longlat'
  'ellps=WGS84'
  'datum=WGS84'
  'no_defs'
  ''
    END
    CLASS
      STYLE
       COLOR 0 0 0
      END
      LABEL
       COLOR 0 0 0
       SIZE SMALL
      END

    END

  END



END

And my openlayers code as follows:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>MAPPING TEST
    <style type="text/css">
        #map {
            width: 90%;
            height: 90%;
            border: 8px solid black;
        }
    </style>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">


      var bounds = new OpenLayers.Bounds(0, 0, 660046, 1229782);
      var map, layer1, layer2;

      var options = { maxExtent: bounds, maxResolution: 600, numZoomLevels:
10};


      function init(){
          map = new OpenLayers.Map('map', options);
      layer1 = new OpenLayers.Layer.WMS("OpenLayers WMS",

      "http://127.0.0.1/cgi-bin/mapserv.exe?", { layers: "UK250", map:
'/ms4w/apps/openlayers-2.5/data/uk2.map' },

      { gutter: 15, minZoomLevel: 1, maxZoomLevel: 4 });

      layer2 = new OpenLayers.Layer.WMS("OpenLayers WMS",

      "http://127.0.0.1/cgi-bin/mapserv.exe?", { layers: "UK", map:
'/ms4w/apps/openlayers-2.5/data/uk2.map' },
      { gutter: 15, minZoomLevel: 5, maxZoomLevel: 10 });

      map.addLayer(layer1, layer2);

      map.zoomToExtent(bounds);
      map.setCenter(bounds);
      map.zoomToMaxExtent();
      map.addControl(new OpenLayers.Control.PanZoomBar());
      map.addControl(new OpenLayers.Control.MousePosition());
      }

    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>

Thanks for any help in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091029/4e359356/attachment.html


More information about the Users mailing list