[mapserver-users] layers not getting separated

sunny74 sb.ray at hotmail.com
Thu Aug 27 01:21:07 EDT 2009


Hi,

Sure the code is as follows:

HTML code:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
     <link href="~/App_Themes/CustomTheme1/Style.css" rel="Stylesheet"
type="text/css" />
    
    <style type="text/css">
        #Button11
        {
            width: 115px;
        }
    </style>
    
</head>
<body onload="init()">
    <form id="form1" runat="server">
    <div id="container">
    <div id="logo" style="width:75px; height:113px; margin-left:
40px;"></div>
    <div id="topbar" style="width:682px; height:113px; top: 0px; left:
2px;"></div>
    <div id="navbar">
        <asp:SiteMapPath ID="SiteMapPath1" runat="server">
        </asp:SiteMapPath>
        </div> 
    <div id="main">
    <div id="column_left">
        <asp:TreeView ID="TreeView1" runat="server"
DataSourceID="SiteMapDataSource1" 
            ImageSet="Contacts" NodeIndent="10">
            <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
            <HoverNodeStyle Font-Underline="False" />
            <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" 
                VerticalPadding="0px" />
            <NodeStyle Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" 
                HorizontalPadding="5px" NodeSpacing="0px"
VerticalPadding="0px" />
        </asp:TreeView>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
        </div>
    <div id="column_center">
    <asp:ContentPlaceHolder id="head" runat="server">
// JS code
<script   type="text/javascript"src="OL27/lib/OpenLayers.js"></script> 
  <script  
type="text/javascript"src="Scripts/CommonAJAXLibrary.js"></script> 
 <!--script type="text/javascript" src="Scripts/WebMap.js"></script-->
 <script type="text/javascript" language="javascript">


     //var map = new OpenLayers.Map(document.getElementById('map'));
     //map = new OpenLayers.Map('map');
     var mapview, layer, layer1, map, layer2, layer3, layer4, highlight,
choice_features, GML, distline;
     var txt1, txt2, txt3, txt4, check1, check2, retA, retB;
     var flag = 0;
     var tmarkers; //var lon = 73.371875;var lat = 18.4283203125;
     var drawControls, result, opt;
     var wktforl = [];
     var condtns = [];
     //OpenLayers.Feature.Vector.style['default']['strokeWidth'] = '2';
     var vector_style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
     vector_style.strokeWidth = 3;
     vector_style.strokeColor = "#ff0000";
     vector_style.fillOpacity = 0;
     vector_style.strokeOpacity = .8;
     var v_style = OpenLayers.Util.extend({},
OpenLayers.Feature.Vector.style['default']);
     v_style.strokeWidth = 3;
     //v_style.strokeColor = "#ff0000";
     v_style.fillOpacity = 0;
     v_style.strokeOpacity = .8;
     v_style.strokeColor = "maroon";
     v_style.fillColor = "maroon";
     v_style.graphicName = "star";
     v_style.pointRadius = 10;
     v_style.rotation = 45;
     v_style.strokeLinecap = "butt";


     function parseData(req) {
         g = new OpenLayers.Format.GML();
         html = ""
         features = g.read(req.responseText);
         for (var feat in features) {
             html += "Feature: Geometry: " + features[feat].geometry + ",";
             html += "<ul>";
             for (var j in features[feat].attributes) {
                 html += "<li>" + j + ":" + features[feat].attributes[j] +
"</li>";
             }
             html += "</ul>"
         }
         //document.getElementById('output').innerHTML = html;
     }



     function init() {

         //alert("in init");
         map = new OpenLayers.Map('<%=map.ClientID%>');

         //
         layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
                "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
'Shape/newwr2.map', layers: 'STATE', 'format': 'png' });

         layer1 = new OpenLayers.Layer.WMS("Rail Main",
                "http://172.16.128.173:8085/cgi-bin/mapserv.exe?", { map:
'Shape/newwr2.map', transparent: 'true', layers: 'Railwayline' });
 highlight = new OpenLayers.Layer.Vector("highlight", { style: vector_style
});
         choice_features = new OpenLayers.Layer.Vector("choice_features", {
style: v_style });
         distline = new OpenLayers.Layer.Vector("distline", { style:
vector_style });
         //GML = new OpenLayers.Layers.GML("GML", { style: v_style });

         //
         map.addLayers([layer,layer1, highlight,distline]);
         //         markers = new OpenLayers.Layer.Markers("markers");
         //         map.addLayer(markers);

         //         map.OpenLayers.Control.PanZoom.destroy();
         //         map.OpenLayers.Control.MouseToolbar.destroy();
         map.zoomToMaxExtent();
         map.setCenter(new OpenLayers.LonLat(79.7, 21.9), 5);

         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());
         map.addControl(new OpenLayers.Control.ScaleLine());

 var radio2 = document.getElementById('Radio2');
         var radio3 = document.getElementById('Radio3');
         var radio4 = document.getElementById('Radio4');
         var radio5 = document.getElementById('Radio5');

         map.events.register("click", map, function(e) {

             if (radio2.checked == 1) {
                 var lonlat = map.getLonLatFromViewPortPx(e.xy);
                 alert("You clicked near " + lonlat.lat + " N, " +
                                          +lonlat.lon + " E");
             }
             if (radio3.checked == 1) {
                 //document.getElementById(dist).style.display = "block";
                 var lonlat1 = map.getLonLatFromViewPortPx(e.xy);
                 alert(lonlat1);
                 //                    var lonlatarr = [2];
                 //                    lonlatarr = lonlat1;
                 //                    alert(lonlatarr);
                 //                   
                 //                    if (lonlatarr.length == 2) {
                 //                    wktforl[0] = GetFeat(lonlatarr[0]);
                 //                     wktforl[1] = GetFeat(lonlatarr[1]);
                 //                        for (var i = 0; i < 2; i++) {
                 //                            
                 //                            alert(wktforl[i]);
                 //                        }
                 //                    }


                 txt1 = document.getElementById('Hidden1');
                 txt2 = document.getElementById('Hidden2');
                 txt3 = document.getElementById('Hidden3');
                 txt4 = document.getElementById('Hidden4');
                 if (txt1.value == '' && txt2.value == '') {
                     txt1.value = lonlat1.lon;
                     txt2.value = lonlat1.lat;
                 }
                 else if (txt1.value != '' && txt2.value != '' && txt3.value
== '' && txt4.value == '') {
                     txt3.value = lonlat1.lon;
                     txt4.value = lonlat1.lat;

                     GetDist();
                 }
                 else {
                     txt1.value = txt3.value;
                     txt2.value = txt4.value;
                     txt3.value = lonlat1.lon;
                     txt4.value = lonlat1.lat;
                     GetDist();
                 }

             }
             if (radio5.checked == 1) {
                 //Get the co-ordinates where user has clicked
                 var lonlat2 = map.getLonLatFromViewPortPx(e.xy);
                 //                  alert("You clicked near " + lonlat2.lat
+ " N, " + 
                 //                                                                     
lonlat2.lon + " E");
                 //                 var msg = getmessage();
                 //                 alert(msg);
                 //                 var pix = new OpenLayers.Pixel(ex, ey);
                 //GetFeature(lonlat2);
                 //Getsum(66, 99);

                 var qry = "select state,pop_tot01 from india_state where
oid=" + '1';
                 var tbl = "india_state";
                 //Rail.WebMap.WebMapService.GetData(tbl, qry,
SucceededCallback, FailedCallback);
                 Idenfeat(lonlat2);

             }
         });
     }
</Script>


Pavel Iacovlev wrote:
> 
> Can we see your OpenLayers JS code ?
> 
> On Wed, Aug 26, 2009 at 3:46 PM, sunny74<sb.ray at hotmail.com> wrote:
>>
>> Dear Friends,
>>
>> I am displaying a map using mapserver and openlayers.The map is displayed
>> using a map file kept within a folder containing shape files.
>> Although the map is getting displayed, if I add more than one layer the
>> layers are not getting separated.
>> i.e I can see the layer in the Layer switcher but if I check or uncheck
>> nothing happens.
>> This means all the layers are coming as a single image.
>> I feel that there is something in the map file which I have ommitted and
>> so
>> this happens.
>> I used QGIS to create the map file.
>>
>> Looking for a solution.
>>
>> Thanks for your replies.
>> --
>> View this message in context:
>> http://n2.nabble.com/layers-not-getting-separated-tp3514899p3514899.html
>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
> 
> 
> 
> -- 
> http://iap.md, The future is open
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/layers-not-getting-separated-tp3514899p3521412.html
Sent from the Mapserver - User mailing list archive at Nabble.com.


More information about the mapserver-users mailing list