I've been experimenting with OpenLayers3 and encountering some difficulty with a getfeatureinfo request. I've been attempting to use ajax for this purpose and convert the response into a GML layer similar to what could be done in OpenLayers2.
Here's the code snippet I'm currently using:
$.ajax({url: GeoServerURL,
data: params,
type: 'POST',
dataType: 'text',
success: function (response) {
console.log('Success!');
var gmlLayer = new ol.format.GML({
featureNS: 'http://www.swansea.gov.uk/',
featurePrefix: 'ccs',
geometryName: 'geom',
extractAttributes: true
});
var results = gmlLayer.writeFeatures(response.responseText);
if (results.length === 0) {
return;
}
}
});
I am aware that the ajax call returns the correct response, and in openlayers 2, I would have used the following command:
results = gmlLayer.read(response.responseText);
This is the XML response from the getFeatures request:
<?xml version="1.0" encoding="UTF-8"?>
<!-- rest of the XML content goes here -->
My goal is to parse the response and display it as a popup while maintaining the structure as a GML feature.