adb-shared 6.2.5 → 6.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,8 @@ import * as i4 from '@angular/forms';
14
14
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule, FormControl, FormGroup, FormArray, Validators, ReactiveFormsModule } from '@angular/forms';
15
15
  import { delay, debounceTime, switchMap, map, catchError as catchError$1, finalize } from 'rxjs/operators';
16
16
  import * as Leaflet from 'leaflet';
17
- import 'leaflet-draw';
17
+ import Leaflet__default from 'leaflet';
18
+ import '@geoman-io/leaflet-geoman-free';
18
19
 
19
20
  class EnvironmentService {
20
21
  constructor(environment) {
@@ -2951,6 +2952,7 @@ class PolygonDrawerInput {
2951
2952
  this.subscriptions = new Subscription();
2952
2953
  this.mapId = "" + Math.floor(Math.random() * Date.now());
2953
2954
  this.polygonDraw = false;
2955
+ this.shapeLayer = null;
2954
2956
  // ControlValueAccessor
2955
2957
  this.onChange = () => { };
2956
2958
  this.onTouched = () => { };
@@ -2971,29 +2973,33 @@ class PolygonDrawerInput {
2971
2973
  this.subscriptions.unsubscribe();
2972
2974
  }
2973
2975
  initDraw() {
2974
- // Clean tooltips
2975
- Leaflet.drawLocal.draw.handlers.rectangle.tooltip = {};
2976
- Leaflet.drawLocal.draw.handlers.simpleshape.tooltip = {};
2977
- Leaflet.drawLocal.draw.handlers.polygon.tooltip = {};
2978
- Leaflet.drawLocal.draw.toolbar.undo.title = "";
2979
- Leaflet.drawLocal.draw.toolbar.finish.title = "";
2980
- Leaflet.drawLocal.draw.toolbar.actions.title = "";
2981
- this.map.on("draw:created", (event) => {
2982
- if (event.layerType === "polygon") {
2983
- this.polygonDraw = false;
2984
- this.clearShape();
2985
- this.shapeLayer = Leaflet.geoJson(event.layer.toGeoJSON());
2986
- this.shapeLayer.interactive = false;
2987
- this.map.addLayer(this.shapeLayer);
2988
- this.map.fitBounds(this.shapeLayer.getBounds());
2989
- this.onChange(event.layer.toGeoJSON());
2990
- }
2976
+ this.map.pm.removeControls();
2977
+ this.map.pm.enableDraw('Polygon', {
2978
+ tooltips: false,
2979
+ finishOn: 'snap',
2980
+ snapDistance: 35,
2981
+ snapMiddle: false
2982
+ });
2983
+ this.map.on("pm:create", (e) => {
2984
+ if (e.shape !== "Polygon")
2985
+ return;
2986
+ this.polygonDraw = false;
2987
+ this.map.pm.disableDraw();
2988
+ this.clearShape();
2989
+ this.shapeLayer = Leaflet__default.geoJSON(e.layer.toGeoJSON(), {
2990
+ interactive: false
2991
+ });
2992
+ this.map.addLayer(this.shapeLayer);
2993
+ this.map.fitBounds(this.shapeLayer.getBounds());
2994
+ this.onChange(e.layer.toGeoJSON());
2995
+ this.map.removeLayer(e.layer);
2991
2996
  });
2992
2997
  }
2993
2998
  renderInitialShape() {
2994
2999
  if (this.geoJson?.type === "Feature") {
2995
- this.shapeLayer = Leaflet.geoJson(this.geoJson);
2996
- this.shapeLayer.interactive = false;
3000
+ this.shapeLayer = Leaflet__default.geoJSON(this.geoJson, {
3001
+ interactive: false
3002
+ });
2997
3003
  this.map.addLayer(this.shapeLayer);
2998
3004
  this.map.fitBounds(this.shapeLayer.getBounds());
2999
3005
  }
@@ -3002,10 +3008,6 @@ class PolygonDrawerInput {
3002
3008
  }
3003
3009
  }
3004
3010
  clearShape() {
3005
- if (this.drawLayer) {
3006
- this.map.removeLayer(this.drawLayer);
3007
- this.drawLayer = null;
3008
- }
3009
3011
  if (this.shapeLayer) {
3010
3012
  this.map.removeLayer(this.shapeLayer);
3011
3013
  this.shapeLayer = null;
@@ -3013,20 +3015,22 @@ class PolygonDrawerInput {
3013
3015
  }
3014
3016
  onDrawPolygon() {
3015
3017
  this.polygonDraw = true;
3016
- this.drawLayer = new Leaflet.Draw.Polygon(this.map, {
3017
- allowIntersection: false
3018
+ this.map.pm.enableDraw("Polygon", {
3019
+ allowSelfIntersection: false,
3020
+ snappable: false
3018
3021
  });
3019
- this.drawLayer.enable();
3022
+ }
3023
+ onUndoStep() {
3024
+ const draw = this.map.pm.Draw?.Polygon;
3025
+ draw?._removeLastVertex();
3020
3026
  }
3021
3027
  onDeleteShape() {
3022
3028
  this.clearShape();
3029
+ this.map.pm.disableDraw();
3023
3030
  this.polygonDraw = false;
3024
3031
  this.onChange(null);
3025
3032
  this.map.setView([62, 17], 5);
3026
3033
  }
3027
- onUndoStep() {
3028
- this.drawLayer?.deleteLastVertex();
3029
- }
3030
3034
  writeValue(geoJson) {
3031
3035
  this.geoJson = geoJson;
3032
3036
  }
@@ -3044,7 +3048,7 @@ class PolygonDrawerInput {
3044
3048
  useExisting: forwardRef((() => PolygonDrawerInput)),
3045
3049
  multi: true
3046
3050
  }
3047
- ], ngImport: i0, template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer||drawLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"fas fa-draw-polygon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n @if (shapeLayer||drawLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"fas fa-times\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"fas fa-undo\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>", dependencies: [{ kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] }); }
3051
+ ], ngImport: i0, template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"fas fa-draw-polygon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"fas fa-times\"></span>\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"fas fa-undo\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>", dependencies: [{ kind: "pipe", type: i1$1.TranslatePipe, name: "translate" }] }); }
3048
3052
  }
3049
3053
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: PolygonDrawerInput, decorators: [{
3050
3054
  type: Component,
@@ -3054,7 +3058,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
3054
3058
  useExisting: forwardRef((() => PolygonDrawerInput)),
3055
3059
  multi: true
3056
3060
  }
3057
- ], template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" [disabled]=\"shapeLayer||drawLayer\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"fas fa-draw-polygon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n @if (shapeLayer||drawLayer) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"fas fa-times\"></span>\r\n </button>\r\n }\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"fas fa-undo\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>" }]
3061
+ ], template: "<div class=\"mb-1 d-flex gap-1 flex-wrap align-items-start\">\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDrawPolygon()\" title=\"Polygon\">\r\n <span class=\"fas fa-draw-polygon\"></span> {{'OBSERVATION.DRAW'|translate}}\r\n </button>\r\n @if (polygonDraw) {\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onDeleteShape()\" title=\"Ta bort\">\r\n <span class=\"fas fa-times\"></span>\r\n </button>\r\n <button class=\"btn btn-secondary\" type=\"button\" (click)=\"onUndoStep()\" title=\"\u00C5ngra\">\r\n <span class=\"fas fa-undo\"></span>\r\n </button>\r\n }\r\n</div>\r\n<div [id]=\"mapId\" class=\"border\" style=\"height:20rem\"></div>" }]
3058
3062
  }] });
3059
3063
 
3060
3064
  var AdbMapFilterType;