Dear Friends,

I am making a WFS Getfeature request and parsing the response of that
request using GML to add a new vector layer over a particular feature of a
layer.

The purpose is to change the color of a one or more features in a layer
So  I have a WMS layer and I am making a WFS GetFeature request for getting
data to create a new vector layer over a feature on the WMS layer.
I have created 2 map files one for wms and other for  wfs because I think a
single map file cannot have both the attributes(correct me if I am wrong).

My code:

<html xmlns="http://www.w3.org/1999/xhtml";>
<head runat="server">
      <title></title>
     <script type="text/javascript"
src="OL28/OL28/lib/OpenLayers.js"></script>
     <script type="text/javascript">

         var mapview, layer, layer1, map, popup, latlon;
         var highlight_style,wfs_url;
    
         function load() {
             //OpenLayers.ProxyHost = "proxy.cgi?url=";
             var lon = 77.384;
             var lat = 28.389;
             var zoom = 9;
             map = new OpenLayers.Map('<%=map.ClientID%>', {
                 controls: [
                    new OpenLayers.Control.PanZoom(),
                    new OpenLayers.Control.Permalink(),
                    new OpenLayers.Control.Navigation()
                ]
             });
              
             //            layer = new OpenLayers.Layer.WMS("OpenLayers
WMS",
             //                "http://localhost:9000/cgi-bin/mapserv.exe?";,
{ map: '../htdocs/Shape/newwr1rec.map', layers: 'STATE', format: 'png' });
             //            layer1 = new OpenLayers.Layer.WMS("Rstations",
             //                "http://localhost:9000/cgi-bin/mapserv.exe?";,
{ map: '../htdocs/Shape/newwr1rec.map', transparent: true, layers:
'RailwayStations', format: 'png' });
             //alert(map);
            
             layer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"/cgi-bin/mapserv.exe?map=C:/Program Files/Apache Software
Foundation/Apache2.2/htdocs/Delhi/Delhi1.map", { 'layers': 'Adminbndy3',
transparent: false, format: "image/png" });
            
             //map.addLayer(layer);
           
//             var defaultStyle = new OpenLayers.Style({
//                 'pointRadius': 10,
//                 'externalGraphic': '${thumbnail}'
             //             });

//             select = new OpenLayers.Layer.Vector("Selection", { styleMap:
//              new
OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
//             });
//             hover = new OpenLayers.Layer.Vector("Hover");
             //map.addLayers(layer);
           
//             control = new OpenLayers.Control.GetFeature({
//                 protocol: OpenLayers.Protocol.WFS.fromWMSLayer(layer),
//                 box: true,
//                 hover: true,
//                 multipleKey: "shiftKey",
//                 toggleKey: "ctrlKey"
//             });
//             control.events.register("featureselected", this, function(e)
{
//                 select.addFeatures([e.feature]);
//             });
//             control.events.register("featureunselected", this,
function(e) {
//                 select.removeFeatures([e.feature]);
//             });
//             control.events.register("hoverfeature", this, function(e) {
//                 hover.addFeatures([e.feature]);
//             });
//             control.events.register("outfeature", this, function(e) {
//                 hover.removeFeatures([e.feature]);
//             });
//             map.addControl(control);
//             control.activate();
             // map.setCenter(new OpenLayers.Bounds(76.507859, 27.613907,
78.439621, 28.941223).getCenterLonLat(), 9);
             // define a blank Vector layer and add it to the map
             highlight_style = { fillColor: '#99CCFF', strokeColor:
'#3399FF', fillOpacity: 0.7 };
             hilites = new OpenLayers.Layer.Vector("Highlighted",
                { isBaseLayer: false, features: [], visibility: true, style:
highlight_style }
            );
                map.addLayer(layer, hilites);
                map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
                map.addControl(new OpenLayers.Control.LayerSwitcher());

                // define the WFS server which will fill requests

                wfs_url =
'/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/Delhi/Delhi1_wfs.map&SERVICE=WFS&VERSION=1.0.0';
            

             

         }
         function highlightFeatures(typename, attribute, value) {
             
             
               alert("wfs_url :"+ wfs_url);
               var wfsurl = wfs_url + '&REQUEST=getfeature&typename=' +
typename +
                 '&Filter=<Filter><PropertyIsEqualTo><PropertyName>' +
attribute + '</PropertyName><Literal>' + value +
'</Literal></PropertyIsEqualTo></Filter>';
               //alert(wfsurl);
                OpenLayers.loadURL(wfsurl,'',null,highlight_them);
               }
 
 
  function highlight_them(response) {
                          // use the GML parser to turn the XML into a list
of Feature objects
      var features = new
OpenLayers.Format.GML().read(response.responseText);
      alert(response.responseText);
                          // have the Vector layer purge its feature list,
replace them with the new ones
                          hilites.destroyFeatures();
                          hilites.addFeatures(features);
                          hilites.setVisibility(true);
                     
   }

   function chfeatcolor() {

       //alert('Hello');
       highlightFeatures('Adminbndy3', 'Polygon_nm', 'Gautam Buddha Nagar');

   }

Now when I call the highlightFeatures() function through my code I get an
error "InvalidparametersValue" -typename does not exist.

so the error says that I given an invalid value for the typename parameter.
As you can see I have given Adminbndy3  as the typename which is the name of
the shapefile and also the wms layer.
So where am I going wrong?
What should I give as value for the typename paremeter?
Let me know if you need the wfs mapfile.

Thanks for your attention and efforts.

-- 
View this message in context: 
http://n2.nabble.com/typename-error-in-WFS-GetFeature-request-tp4860968p4860968.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to