[OpenLayers-Users] zoom to different WMS layers

Paul Curran paulcurran9 at googlemail.com
Mon Aug 24 09:48:06 EDT 2009


Hi,



I wish to have a map of the UK with different layers being displayed
depending on how close I am zoomed into the map.



Currently I can view a map of the UK which displays fine via OpenLayers.
However I can only view the first layer of my map (  a 1:50000 scaled image
of the UK). I wish to zoom in to the next layer of the UK (a 1:250 000
scaled image of the UK)



Is this possible with Openlayers?



Any help greatly appreciated



My code is below



Cheers



<script type="text/javascript">



      var zoom = 10;

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

      var map, layer;





      function init(){

          map = new OpenLayers.Map('map', { maxExtent: bounds,
maxResolution: 156543, units: 'meters',

          projection: "EPSG:4326", numZoomlevels: 10 });

      map.addControl(new OpenLayers.Control.PanZoomBar());

      map.addControl(new OpenLayers.Control.OverviewMap());

      map.addControl(new OpenLayers.Control.MousePosition());

      layer = 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 });

      map.addLayer(layer);

      map.zoomToExtent(bounds);

      map.setCenter(bounds);



      }



    </script>



MAP



    NAME UK1

            PROJECTION

    'proj=longlat'

    'ellps=WGS84'

    'datum=WGS84'

    'no_defs'

    ''

    END

    SIZE 1600 1200

    IMAGECOLOR  153 204 255

    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 1229782

    UNITS METERS





            WEB

              TEMPLATE "http://localhost/openlayers/examples/uktest.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 "UK"

               METADATA

                 'wms_title' "wms_demo"

               END

               STATUS DEFAULT

               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



  LAYER



               NAME "250"

               METADATA

                 'wms_title' "wms_demo"

               END

               STATUS DEFAULT

               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







END
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090824/19f020d9/attachment.html


More information about the Users mailing list