Skip to content

Commit

Permalink
fix: duplicated geom "not saved" on edition
Browse files Browse the repository at this point in the history
- Refact and manage use case where the user wants
to create new geometrie  --> saved --> and wants to edit
the geom created

Reviewed-by: andriacap
  • Loading branch information
andriacap committed Sep 18, 2024
1 parent d5cca73 commit 792498e
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,29 @@ export class LeafletDrawComponent implements OnInit, OnChanges {
});

this.map.on(this._Le.Draw.Event.DRAWSTOP, (e) => {
if (this._currentGeojson) {
const layer: L.Layer = this.mapservice.createGeojson(this._currentGeojson.geometry, false);
if (!this.mapservice.leafletDrawFeatureGroup.hasLayer(layer)) {
this.loadDrawfromGeoJson(this._currentGeojson.geometry);
}
const geojson = this._currentGeojson?.geometry || this.geojson;

if (this._currentDraw) {
this.handleDrawStopWithCurrentDraw(geojson);
} else {
this.handleDrawStopWithoutCurrentDraw(geojson);
}
});
}
handleDrawStopWithCurrentDraw(geojson: any): void {
if (!this.mapservice.leafletDrawFeatureGroup.hasLayer(this._currentDraw) && geojson) {
this.loadDrawfromGeoJson(geojson);
}
}

handleDrawStopWithoutCurrentDraw(geojson: any): void {
this.mapservice.removeAllLayers(this.map, this.mapservice.fileLayerFeatureGroup);
const layer: L.Layer = this.mapservice.createGeojson(geojson, false);

if (!this.mapservice.leafletDrawFeatureGroup.hasLayer(layer)) {
this.loadDrawfromGeoJson(geojson);
}
}

getGeojsonFromFeatureGroup(layerType) {
let geojson: any = this.mapservice.leafletDrawFeatureGroup.toGeoJSON();
Expand Down

0 comments on commit 792498e

Please sign in to comment.