Open edwin-cox opened 9 years ago
Sounds a bit difficult to implement that effectively to me. But you could just use OLVectorSource.updateFeature(featurePoly) for refreshing the changes.
Here the code, it is not the 'neatest' solution in my eyes - but it does the job. This passage:
@Override
public void buttonClick(ClickEvent event) {
OLStyle olStyle =StyleUtils.createDefaultStyle();
olStyle.fillStyle=new OLFillStyle("red");
featurePoly.setStyle(olStyle);
}
has to be replaced with this code:
@Override
public void buttonClick(ClickEvent event) {
OLStyle olStyle =StyleUtils.createDefaultStyle();
olStyle.fillStyle=new OLFillStyle("red");
featurePoly.setStyle(olStyle);
((OLVectorSource)vectorLayer.getSource()).updateFeature(featurePoly);
}
Btw. added this feature inspired by this issue:
((OLVectorSource)vectorLayer.getSource()).updateAllFeatures();
When one attribute of a feature, like geometry or style, is changed, it doesn't repercute to the canvas. In the demo here, a polygon is created with one button. The two other buttons should modify its geometry or color.