Monday 25 February 2019

How to add GeoServer wfs layer on OpenLayers?


I can't seem to add a WFS layer like this. It works when i copy all this code locally but as soon as i change the values to point to my own layer within my own GeoServer


this is the response viewed in firebug:



Could not locate {http://www.mydomain.com/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=catalog:dataSAR}dataSAR in catalog



This is the relevant part of my javascript:


    var wfs = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],

protocol: new OpenLayers.Protocol.WFS({
url: "http://www.mydomain.com/geoserver/wfs",
featurePrefix:"catalog",
featureType: "dataSAR",
featureNS: "http://www.mydomain.com/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=catalog:dataSAR",
geometryName: "bounds"

}),
styleMap: new OpenLayers.StyleMap({
strokeWidth: 3,

strokeColor: "#333333"
})
})

map.addLayers([basemap, wfs]);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);

And this is what my DescribeFeature (featureNS) looks like:


   
-


-
-
-
-





































Answer



You need the actual URI/URL for your workspace. From your DescribeFeature Schema it looks like "catalog" which is weird. The other option is to go to the workspace menu in the UI and look there



enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...