I'm using GeoExt, OpenLayers and GeoServer. I've added a checkbox to my layer tree which, when clicked, activates a "select feature" control such that when a user clicks on the map, the feature clicked on is highlighted. My code is:
'checkchange': function(node, checked) {
if (checked === true) {
app.mapPanel.map.addLayer(node.attributes.layer);
mySelectLayer = new OpenLayers.Layer.Vector("Selection", {
styleMap: new OpenLayers.Style(OpenLayers.Feature.Vector.style["select"])
});
app.mapPanel.map.addLayer(mySelectLayer);
myLayerCtrl = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(node.attributes.layer),
box: true,
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
myLayerCtrl.events.register("featureselected", this, function(e){
mySelectLayer.addFeatures([e.feature]);
});
app.mapPanel.map.addControl(myLayerCtrl);
myLayerCtrl.activate();
} else {
app.mapPanel.map.removeLayer(node.attributes.layer);
app.mapPanel.map.removeLayer(mySelectLayer);
myLayerCtrl.deactivate();
}
}
However, when a user clicks on the map the following exception is thrown by GeoServer:
org.geoserver.platform.ServiceException: No such operation WMS 1.1.0 GetFeature
I've found a number of posts on this, but no solutions. Any idea about what is causing this problem? Thanks in advance.
UPDATE: I've read that this error is as a result of the request being sent to WMS, as opposed to WFS service. My assumption, however, is that it should be possible for OpenLayers to deduce the WFS service. From the OpenLayers documentation here, the protocol parameter kind of takes care of ensuring WFS, and not WMS, is used, in my opinion. Any idea is welcome.