是否可以在运行时在 Geotools 的 MapContent 对象(图层)上绘制要素?

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

我正在使用 Geotools 并尝试在 运行 时编辑现有图层。 基本上我有一个图层,我已将其添加到 MapContent 对象,然后将其投影到 JFrame 上。现在我想知道的是,我们是否可以在 JFrame 上的这个显示上手动绘制一些特征,通过绘制一些特征(可以是点或多边形)来编辑这一层。

是的,这完全有可能。您将需要 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),然后将其添加到图层中。