[mapserver-users] RE: mapserver-users Digest, Vol 51, Issue 11

Özgür Arslan ozgurarslan81 at hotmail.com
Mon Apr 9 16:44:26 EDT 2012


Fernando,fernando at globalgeo.com.br      mapserver-users at lists.osgeo.org

Thanks for your respond I really appreciate it.  Also yes I am using   map.addControl(new OpenLayers.Control.LayerSwitcher());  
In this Html codes how can I create a second layer by using same map file that I can switch off and on near the base map? 

My html file is below:

Thanks again.

<!-- MapServer Template -->
<html>
<head>
  <title>OpenLayers Example</title>
   <link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    </head>
    <body>
      <center><div id="map"></div></center>
      <style>
    @media screen
    {
        #map{width:975px; height:750px; border: 2px solid black;}
    }
    </style>
      <script defer="defer" type="text/javascript">
        var lon = -84.722147;
        var lat = 49.298594;    
        var zoom = 6;
        var map, layer;
         
        map = new OpenLayers.Map( 'map' );
        layer1 = new OpenLayers.Layer.WMS( "QGIS-MAP1", 
                    "http://localhost/cgi-bin/mapserv.exe", {layers: 'ResidentDistrict_2011',map: '/wwwroot/Example/Mountains.map'},
                    {gutter: 15});
                    
        layer2 = new OpenLayers.Layer.WMS( "QGIS-MAP2", 
                    "http://localhost/cgi-bin/mapserv.exe", {layers: 'bDI_2011_GOLD',map: '/wwwroot/Example_test/Mountains.map'},
                    {gutter: 15});            
        map.addLayer(layer1, layer2);

        map.zoomToMaxExtent();  
        map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
        
        map.addControl(new OpenLayers.Control.MouseToolbar());
        map.addControl(new OpenLayers.Control.LayerSwitcher());
        map.addControl(new OpenLayers.Control.MousePosition());
        map.addControl(new OpenLayers.Control.OverviewMap());
        
      </script>

</body>
</html>


Date: Mon, 9 Apr 2012 17:18:22 -0300
Subject: Re: [mapserver-users] RE: mapserver-users Digest, Vol 51, Issue 11
From: fernando at globalgeo.com.br
To: ozgurarslan81 at hotmail.com
CC: mapserver-users at lists.osgeo.org

Ozgur,
You said that layers are BASE layers. Base layers can't switch to off an on, there is only one base layer active, there you can switch between them. Are you using the OpenLayers.Control.LayerSwitcher, to see the layers? 

In the openlayers.layer.wms you can set this as not a base layer, as options.. after {}, { isBaseLayer: false }But remember a base layer need to exist, and there is a way to include a 'blank' layer as base layer.

Good luck,




2012/4/9 Özgür Arslan <ozgurarslan81 at hotmail.com>








     Hi ALL,

Thanks for all responds. I tryed all suggestions and when I use these lines it only shows layer1 like a base map and I can't switch off and on. I would like create 3 separate layer that I can switch off and on each layer individually.

Furthermore when I change the layer orders from map.addLayers([layer1,layer2,layer3]); to map.addLayers([layer2,layer1,layer3]); this time it only shows 
the second layer(layer2) as a base layer and I can't switch off and on. Could you please share your ideas with me about the issue?


Thank you

 
layer1 = new OpenLayers.Layer.WMS( "QGIS-MAP","
> http://localhost/cgi-bin/mapserv.exe", {layers:
> 'ResidentDistrict_2011',map:

> '/wwwroot/example1_test/Canada_Mountains.map',} )
>
> layer2 = new OpenLayers.Layer.WMS( "QGIS-MAP","
> http://localhost/cgi-bin/mapserv.exe", {layers: 'LAKES',map:

> '/wwwroot/example1_test/Canada_Mountains.map',} )
>
> layer3 = new OpenLayers.Layer.WMS( "QGIS-MAP","
> http://localhost/cgi-bin/mapserv.exe", {layers: 'BDI_2011',map:

> '/wwwroot/example1_test/Canada_Mountains.map',} )
>
> map.addLayers([layer1,layer2,layer3]);


here are the html codes


<html>
<head>
  <title>OpenLayers Example</title>

   <link rel="stylesheet" href="openlayers/theme/default/style.css" type="text/css">


    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    </head>
    <body>
      <center><div id="map"></div></center>



      <style>
    @media screen
    {
        #map{width:975px; height:750px; border: 2px solid black;}
    }
    </style>
      <script defer="defer" type="text/javascript">



        var lon = -84.722147;
        var lat = 49.298594;    
     
        var zoom = 6;
        var map, layer;
      
        map = new OpenLayers.Map('map');
        layer = new OpenLayers.Layer.WMS( "QGIS-MAP",



            "http://localhost/cgi-bin/mapserv.exe", {layers: 'ResidentDistrict_2011,LAKES,BDI_2011',map: '/wwwroot/example1_test/Canada_Mountains.map',} )



        
        map.addLayer(layer);
        map.zoomToMaxExtent();  
        map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
        
        map.addControl(new OpenLayers.Control.PanZoomBar());



        map.addControl(new OpenLayers.Control.MouseToolbar());
        map.addControl(new OpenLayers.Control.LayerSwitcher());
        map.addControl(new OpenLayers.Control.MousePosition());
        map.addControl(new OpenLayers.Control.OverviewMap());



      </script>

</body>
</html>

 		 	   		  

_______________________________________________

mapserver-users mailing list

mapserver-users at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapserver-users



 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20120409/16f35e82/attachment-0001.html


More information about the mapserver-users mailing list