For starters, I went off the example at http://openlayers.org/dev/examples/wfs-reprojection.js and got that working just fine with the states vector layer showing up.

Now I'm trying to use my own mapfile (wfs_navdata_02.map) and do the same. Just one layer for now, cities_1x.

var wfs = new OpenLayers.Layer.Vector("My Layer", {
            strategies: [new OpenLayers.Strategy.Fixed()],
            protocol: new OpenLayers.Protocol.WFS({
                version: "1.1.0",
                srsName: "EPSG:4326",
                url:  "http://my_local_url/cgi-bin/mapserv.exe?map=/file_location/wfs_navdata_02.map",
                featureType: "cities_1x",
                featurePrefix: "",
                featureNS: "http://yourdomain/application/catalogLayer"

What do I put in for featureNS? For the url, is referencing the mapfile like that ok? I read one poster that said he needed to use featurePrefix but I don't think thats necessary here.

Also for featureType, is that the name of the LAYER or the wms_title within the layer?

I've successfully used WMS before but WFS is a bit more confusing. I am not having any errors in the javascript console via Chrome.

Snippet of mapfile can be seen here: http://codeshare.io/C1hki

Not sure if OUTPUTFORMAT is necessary.

Any input is appreciated.


This might help you move forward: by default, MapServer uses "ms:" as a prefix, and http://mapserver.gis.umn.edu/mapserver as a namespace:

featurePrefix: "ms",
featureNS: "http://mapserver.gis.umn.edu/mapserver"

OpenLayers might/did have some quirks when specifying both of these, so you might want to try setting only one of those at a time, c.f. http://lists.osgeo.org/pipermail/openlayers-users/2009-August/013320.html


You can also try with version: '1.0.0' as this will prevent lat/lon coordinate inversion. I also found a few issues with your mapfile:

  • The mapfile should end with an END at the map level.
  • The OUTPUTFORMAT is not mandatory.
  • Make sure to use "init=epsg:4326" as your projection.

Using the NameSpace and prefix above and fixing the mapfile, I successfully got points in OpenLayers.

  • Thomas, appreciate the answer. Good looking on the version 1.0.0. I had 1.1.0 and this was causing an issue (I ended up using Country_Borders instead of cities_1x) and it was flipped vertically instead of aligned correctly. Ill update my initial question with some code and a screenshot. – Nubtacular Oct 29 '13 at 16:29

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.