2

I have used following map file to create the WFS service on MapServer but struggling to display the service output using OpenLayers.

Please suggest some links to use WFS service in OpenLayers.

MAP
  NAME "WFS_server"
  STATUS ON
  SIZE 600 300
  UNITS DD
  IMAGECOLOR 255 255 255   
  #
  # 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 "Mumbai_City"
    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/Mumbai_City_Boundry.shp'
    PROJECTION
      "init=epsg:4326"
    END
    CLASS
      NAME 'Mumbai City'
      STYLE
        COLOR 255 128 128
        OUTLINECOLOR 96 96 96
      END
    END
  END #layer   
END #mapfile
  • 1
    can you add what you have tried so far and why/what is not working for you. Otherwise the question is too broad to answer – Ian Turton Jun 1 '12 at 9:45
  • I have used WMS and MapServer and it is working fine But the WFS and Vector service is not working. – Gunner Jun 1 '12 at 10:20
  • The MapFile I have used is it valid...??? and please suggest some link WFS sevice on mapserver and use in the openlayers... – Gunner Jun 1 '12 at 10:23
  • Before trying to work out whether your service can be called through OpenLayers, you should try to see if you can get a GetCapabilities request working in a browser. If there are any errors with the map file then running a GetCapabilities request will reveal those issues – nmtoken Dec 14 '16 at 23:53
4

you can check out this example here for source code - MapServer WFS Demo and OpenLayers 2.10 SLD support for vector styles.

Beside this you can glance at:

  • MapServer and OpenLayers configuration here

  • WFS: WA National Parks Example, here

and your wfs call for vector layer similir to this:

lyr = new OpenLayers.Layer.Vector("WFS protocol continents", {
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: new OpenLayers.Protocol.WFS({
                      "url": url,
                      "propertyNames": propertyNames,
                      "geometryName": "msGeometry",
                      "featureType": "continents",
                      "featurePrefix": "ms",
                      "srsName": "EPSG:4326",
                      "maxFeatures": 1000,
                      "version": "1.0.0"
                  })
    });

i hope it helps you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.