This may be simple question but I can't get started. This tutorial from pen state university has xml request
outputFormat="GML2" – we would like gml2 as the return format
xmlns:topp="http://www.openplans.org/topp"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd">
we want to query
bc_roads features
only return features
with an ID of bc_roads.1
My question here is how do I send this request to geoserver using geoext or javascript?
Answer
You can do a post request in OpenLayers like this:
var postData = ""; //insert your data to post here
var request = new OpenLayers.Request.POST({
url: "http://host/path",
data: postData,
headers: {
"Content-Type": "text/xml;charset=utf-8"
},
callback: function (response) {
//read the response from GeoServer
var gmlReader = new OpenLayers.Format.GML({ extractAttributes: true });
var features = gmlReader.read(response.responseText);
// do what you want with the features returned...
},
failure: function (response) {
alert("Something went wrong in the request");
}
});
You can see more examples of how to request data in OpenLayers here:
No comments:
Post a Comment