|
From: John P. <byh...@gm...> - 2011-01-09 18:21:22
|
I'm trying to get get the info and geometry of a feature after
clicking on a wms layer of it. I have the info part working using the
GetFeatureInfo contol as below.
WMSGetFeatureInfoOptions options = new WMSGetFeatureInfoOptions();
options.setURL(http://localhost:8086/geoserver/wms");
options.setTitle("Query visible layers");
options.setQueryVisible(true);
featureInfo = new WMSGetFeatureInfo(options);
featureInfo.addGetFeatureListener(new GetFeatureInfoListener()
{
public void onGetFeatureInfo(GetFeatureInfoEvent eo)
{
show(eo.getText());
}
});
map.addControl(featureInfo);
To get the geometry to highlight the selected layer I tried a number
of methods but the one that gets me closest is the GetFeature control
(as below) that I see in Firebug is POSTing a request and getting the
geometry in response. However I cannot how to attach a event listener
to get access to the response.
// Create the styles for each selectFeature purpose
Style styleNormal = createStyle("#FF0000");
Style styleSelected = createStyle("#00FF00");
Style styleHighlighted = createStyle("#0000FF");
// Create the StyleMap to handle all styles
StyleMap styleMapVector = new StyleMap(styleNormal, styleSelected,
styleHighlighted);
// Create the vectorOptions to use the styles
VectorOptions vectorOptions = new VectorOptions();
vectorOptions.setStyleMap(styleMapVector);
vectorOptions.setIsBaseLayer(false);
vectorOptions.setVisibility(true);
Vector vlayer = new Vector("SelectFeature Layer", vectorOptions);
map.addLayer(vlayer);
GetFeatureOptions featureOptions = new GetFeatureOptions();
featureOptions.setProtocol(new WFSProtocol(wmsLayer, new WFSProtocolOptions()));
featureOptions.setBox(true);
featureOptions.setHover(false);
featureOptions.setMultipleKey("shiftKey");
featureOptions.setToggleKey("ctrlKey");
GetFeature f = new GetFeature(featureOptions);
map.addControl(f);
f.activate();
Can anyone show me how to attach an event handler to trap the
getfeature requests response to add to the vLayer that I will use to
make it visible, similar to how it shows up in the Selectfeature
control. However when I tried that control I got no POST events
triggered by the mouse click to request any feature from the server.
John
|