Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been working for last 15 days to connect setup the WFS service on Mapserver into OpenLayers I tried examples from Mapserver but did not work out .Following is the Map file code snippet

MAP
NAME "WFS_server"
STATUS ON
SIZE 400 300
SYMBOLSET "etc/symbols.txt"
EXTENT -180 -90 180 90
UNITS DD
  SHAPEPATH "../data"
IMAGECOLOR 255 255 255
FONTSET "etc/fonts.txt"


#
# Start of web interface definition
#
WEB
  IMAGEPATH "/ms4w/tmp/ms_tmp/"
  IMAGEURL "/ms_tmp/"
  METADATA
    "wfs_title"          "WFS Demo Server for MapServer" ## REQUIRED
    "wfs_onlineresource" "http://demo.mapserver.org/cgi-bin/wfs?" ## Recommended
    "wfs_srs"            "EPSG:4326 EPSG:4269 EPSG:3978 EPSG:3857" ## Recommended
    "wfs_abstract"       "This text describes my WFS service." ## Recommended
    "wfs_enable_request" "*"  # necessary
  END
END

PROJECTION
  "init=epsg:4326"
END

#
# Start of layer definitions
#

##################
# World Continents
##################
LAYER
  NAME continents
  METADATA
    "wfs_title"         "World continents" ##REQUIRED
    "wfs_srs"           "EPSG:4326" ## REQUIRED
    "gml_include_items" "all" ## Optional (serves all attributes for layer)
    "gml_featureid"     "ID" ## REQUIRED
    "wfs_enable_request" "*"
  END
  TYPE POLYGON
  STATUS ON
  DATA '/ms4w/data/World_Boundary.shp'
  PROJECTION
    "init=epsg:4326"
  END
  CLASS
    NAME 'World Continents'
    STYLE
    COLOR 255 128 128
    OUTLINECOLOR 96 96 96
  END
END
END #layer

END #mapfile

Below is my Html file.

<html>
<head>
    <title>New App</title>
    <link rel="stylesheet" href="theme/default/style.css" type="text/css">
    <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js">     </script>

        <link rel="stylesheet" type="text/css"     href="http://api.geoext.org/1.1/resources/css/geoext-all.css" />
<script  type="text/javascript">
    function inicializacija() {
        var options = {
            projection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 200,
            maxResolution: 156543.0339,
            //maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34,     20037508.34)
    };
    var popup;
    var map = new OpenLayers.Map("map-id", options);
    var wms1 = new OpenLayers.Layer.MapServer("Mumbai City", "http://localhost/cgi-bin/mapserv.exe", { layers: 'Mumbai_City', map: '/ms4w/Apache/htdocs/demos/WFSdemo.map', srs: 'EPSG:4326' });
    var wms = new OpenLayers.Layer.WMS("World Map", "http://localhost/cgi-bin/mapserv.exe", { layers: 'countries', map: '/ms4w/Apache/htdocs/demos/demo.map', srs: 'EPSG:4326' });        


    var wmst = new OpenLayers.Layer.Vector("WFS", {
                strategies: [new OpenLayers.Strategy.BBOX()],
                protocol: new OpenLayers.Protocol.WFS({
                    url:  "http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/demos/WF.map",
                    featureType: "continents",
                    featureNS: "http://www.openplans.org/topp"
                })
            });  

    var lyr = new OpenLayers.Layer.Vector("WFS protocol continents", {
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: new OpenLayers.Protocol.WFS({
                  "url": "http://localhost/cgi-bin/mapserv.exe?map=c:/ms4w/Apache/htdocs/demos/WF.map",
                  "propertyNames": "continents",
                  "geometryName": "msGeometry",
                  "featureType": "continents",
                  "featurePrefix": "ms",
                  "srsName": "EPSG:4326",
                  "maxFeatures": 1000,
                  "version": "1.0.0"
              })
});

    map.addLayers([wms1, wms, wmst, lyr]);
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.MousePosition());
    map.addControl(new OpenLayers.Control.Scale());
    map.addControl(new OpenLayers.Control.ScaleLine());

   map.zoomToExtent(new OpenLayers.Bounds(56.00, 35.00, 104.0, 8.000));  //1490000, 5600000, 1850000, 5900000
}
</script>
    <style>
        #map-id {
            width: 100%;
            height: 100%;
        }
</style>
</head>
<body onload= 'inicializacija()'>
    <h1>New App</h1>
    <div id="map-id"></div>
</body>
</html>

The WMS layers(wms,WMS1) is working fine but when it comes to WFS layer the it shows the layer name into layer selector but the layer is not visible into map control.Thank you in advance and please point me where i am getting wrong. What should come to wfs layer attributes please suggest me.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.