Search code examples
geospatialgeotools

Is it possible to draw a feature on a MapContent object (layer) in Geotools at runtime?


I am working on Geotools and trying to edit an existing layer at run time. Basically I have a layer which I have added on to a MapContent object, which I then project it on JFrame. Now what I want to know is that can we manually draw some features on this showing on JFrame to edit this layer by drawing some features( which could be either a point or a polygon).


Solution

  • Yes, that is perfectly possible. You will need a Swing tool to handle the drawing and then some way to add any needed attributes to the geometry to make a new feature (see SimpleFeatureBuilder) and then add that to the layer.