// Path: src/main/java/de/bayern/gdi/gui/map/MapHandler.java
// public static final String POLYGON_LAYER_TITLE = "PolygonLayer";


import com.sothawo.mapjfx.Coordinate;
import com.sothawo.mapjfx.CoordinateLine;
import com.sothawo.mapjfx.MapView;
import javafx.scene.paint.Color;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.GeometryAttributeImpl;
import org.geotools.map.MapLayer;
import org.geotools.map.event.MapLayerListEvent;
import org.geotools.map.event.MapLayerListListener;
import org.locationtech.jts.geom.Polygon;
import org.opengis.feature.Feature;
import org.opengis.feature.Property;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static de.bayern.gdi.gui.map.MapHandler.POLYGON_LAYER_TITLE;
        this.mapView = mapView;
    }

    @Override
    public void layerAdded(MapLayerListEvent mapLayerListEvent) {
        MapLayer layer = mapLayerListEvent.getLayer();
        if (POLYGON_LAYER_TITLE.equals(layer.getTitle())) {
            try {
                FeatureIterator features = layer.toLayer().getFeatureSource()
                    .getFeatures().features();
                while (features.hasNext()) {
                    Feature feature = features.next();
                    Property id = feature.getProperty("id");
                    Property geometry = feature.getProperty("geometry");
                    if (id != null && geometry != null) {
                        Polygon polygon = (Polygon) ((GeometryAttributeImpl)
                            geometry).getValue();
                        String polygonId = id.getValue().toString();
                        createAndAddCoordinateLine(polygonId, polygon);
                    }
                }
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    }

    @Override
    public void layerRemoved(MapLayerListEvent mapLayerListEvent) {
        String title = mapLayerListEvent.getLayer().getTitle();
// Path: src/main/java/de/bayern/gdi/gui/map/MapHandler.java
// public static final String POLYGON_LAYER_TITLE = "PolygonLayer";


// Path: src/main/java/de/bayern/gdi/gui/map/PolygonsOnMapViewHandler.java
import com.sothawo.mapjfx.Coordinate;
import com.sothawo.mapjfx.CoordinateLine;
import com.sothawo.mapjfx.MapView;
import javafx.scene.paint.Color;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.GeometryAttributeImpl;
import org.geotools.map.MapLayer;
import org.geotools.map.event.MapLayerListEvent;
import org.geotools.map.event.MapLayerListListener;
import org.locationtech.jts.geom.Polygon;
import org.opengis.feature.Feature;
import org.opengis.feature.Property;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static de.bayern.gdi.gui.map.MapHandler.POLYGON_LAYER_TITLE;

        this.mapView = mapView;
    }

    @Override
    public void layerAdded(MapLayerListEvent mapLayerListEvent) {
        MapLayer layer = mapLayerListEvent.getLayer();
        if (POLYGON_LAYER_TITLE.equals(layer.getTitle())) {
            try {
                FeatureIterator features = layer.toLayer().getFeatureSource()
                    .getFeatures().features();
                while (features.hasNext()) {
                    Feature feature = features.next();
                    Property id = feature.getProperty("id");
                    Property geometry = feature.getProperty("geometry");
                    if (id != null && geometry != null) {
                        Polygon polygon = (Polygon) ((GeometryAttributeImpl)
                            geometry).getValue();
                        String polygonId = id.getValue().toString();
                        createAndAddCoordinateLine(polygonId, polygon);
                    }
                }
            } catch (IOException e) {
                LOG.error(e.getMessage(), e);
            }
        }
    }

    @Override
    public void layerRemoved(MapLayerListEvent mapLayerListEvent) {
        String title = mapLayerListEvent.getLayer().getTitle();
        if (POLYGON_LAYER_TITLE.equals(title)) {