We are working on our Gis application, I am using gwt-openlayers and we're creating Vaadin wrappers.
So I've extended the MapWidget and created the required layers and vector layers and added a DrawFeatureControl:
DrawFeatureOptions drawFeatureOptions = new DrawFeatureOptions();
private DrawFeature drawFeaturePoint = = new DrawFeature(vectorLayer, new PointHandler(), drawFeatureOptions);
and to catch the event:
getWidget().getDrawFeatureOptions().onFeatureAdded(new () {
@Override
public void (com.openlayers.client.feature.VectorFeature vectorFeature) {
Window.alert("Feature Added" + vectorFeature.getFID());
serverRpc.featureAdded(buildVectorFeature(vectorFeature));
}
});
for some reason this is not working; although the following which should be almost the same is working fine:
getWidget().getVectorLayer().addVectorFeatureSelectedListener(new () {
@Override
public void onFeatureSelected(FeatureSelectedEvent eventObject) {
serverRpc.featureSelected(buildVectorFeature(eventObject.getVectorFeature()));
}
});
using (addVectorFeatureAddedListener) on the vector layer will be fired everytime a Feature is added to the VectorLayer, and will not be fired when the DrawFeatureControl is used. Can someone help me to catch the Features that are drawn using the DrawFeatureControl.
By The way I have a Cluster and BBox stratigies on the MapWidget, I don't know if this changes anything.
I found it, for some reason
doesn't do the trick, I had to inject the listener in GWT using: