From 4f6a22104aa18ee0b6526461776a9db8d227552e Mon Sep 17 00:00:00 2001 From: Matthias Stein Date: Sat, 2 Dec 2023 14:30:49 +0100 Subject: [PATCH] Add snappingGroupLayerId --- src/main/js/apps/sample/app.json | 28 +++++++++++ .../js/bundles/dn_sketchingenhanced/README.md | 50 +++++++++++++++++++ .../SketchingEnhancedController.ts | 10 ++++ .../SketchingEnhancedModel.ts | 2 + .../dn_sketchingenhanced/manifest.json | 1 + 5 files changed, 91 insertions(+) diff --git a/src/main/js/apps/sample/app.json b/src/main/js/apps/sample/app.json index 7c3c143..0fadec4 100644 --- a/src/main/js/apps/sample/app.json +++ b/src/main/js/apps/sample/app.json @@ -47,6 +47,7 @@ "snappingEnabled": true, "snappingSelfEnabled": true, "snappingFeatureEnabled": true, + "snappingGroupLayerId": "snapping_layer", "pointSymbol": { "type": "simple-marker", "style": "circle", @@ -250,6 +251,31 @@ ], "map": { "layers": [ + { + "id": "snapping_layer", + "title": "Snapping Layer", + "type": "GROUP", + "listMode": "hide", + "visible": false, + "layers": [ + { + "id": "grenzen_1", + "title": "Kreise", + "type": "AGS_FEATURE", + "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/FeatureServer/1", + "maxScale": 250000, + "minScale": 1000000 + }, + { + "id": "grenzen_2", + "title": "Länder", + "type": "AGS_FEATURE", + "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/FeatureServer/2", + "maxScale": 1000000, + "minScale": 10000000 + } + ] + }, { "id": "fliessgewaesser", "title": "Fließgewässer", @@ -265,6 +291,8 @@ { "id": "grenzen", "title": "Grenzen", + "type": "GROUP", + "visible": false, "layers": [ { "id": "grenzen_0", diff --git a/src/main/js/bundles/dn_sketchingenhanced/README.md b/src/main/js/bundles/dn_sketchingenhanced/README.md index dc70f03..c8e09e9 100644 --- a/src/main/js/bundles/dn_sketchingenhanced/README.md +++ b/src/main/js/bundles/dn_sketchingenhanced/README.md @@ -31,6 +31,7 @@ To configure the bundle in app.json, use the configurable properties shown in th "snappingEnabled": true, "snappingSelfEnabled": true, "snappingFeatureEnabled": true, + "snappingGroupLayerId": "snapping_layer", "pointSymbol": { "type": "simple-marker", "style": "circle", @@ -123,6 +124,7 @@ To configure the bundle in app.json, use the configurable properties shown in th | snappingEnabled | Boolean | ```true``` | ```false``` | ```true``` | Global configuration to turn snapping on or off. | | snappingSelfEnabled | Boolean | ```true``` | ```false``` | ```true``` | Global configuration option to turn self snapping (within one feature while either drawing or reshaping) on or off. | | snappingFeatureEnabled | Boolean | ```true``` | ```false``` | ```true``` | Global configuration option to turn feature snapping on or off. | +| snappingGroupLayerId | String | | ```null``` | Define a group layer id to enable some snapping layers if the Sketching Enhanced tool gets started. | | pointSymbol | Object | | | A SimpleMarkerSymbol, PointSymbol3D, CIMSymbol, or WebStyleSymbol used for representing the point geometry that is being drawn. | | polylineSymbol | Object | | | A SimpleLineSymbol, LineSymbol3D, or CIMSymbol used for representing the polyline geometry that is being drawn. | | polygonSymbol | Object | | | A SimpleFillSymbol, PolygonSymbol3D, or CIMSymbol used for representing the polygon geometry that is being drawn. | @@ -144,6 +146,54 @@ To disable snapping on layers you need to set _allowSnapping_ to false. } } ``` + +### Add group layer that contains snappable layers. The group layer will be enabled if the sketching enhanced tool gets started. + +#### 1. Add group layer to map +```json +"map": { + "layers": [ + { + "id": "snapping_layer", + "title": "Snapping Layer", + "type": "GROUP", + "listMode": "show", + "visible": false, + "layers": [ + { + "id": "grenzen_1", + "title": "Kreise", + "type": "AGS_FEATURE", + "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/FeatureServer/1", + "maxScale": 250000, + "minScale": 1000000 + }, + { + "id": "grenzen_2", + "title": "Länder", + "type": "AGS_FEATURE", + "url": "https://services.conterra.de/arcgis/rest/services/common/grenzen/FeatureServer/2", + "maxScale": 1000000, + "minScale": 10000000 + } + ] + } + ] +} +``` + +#### 2. Configure snappingGroupLayerId + +```json +"dn_sketchingenhanced": { + "Config": { + ... + "snappingGroupLayerId": "snapping_layer", + ... + } +} +``` + ### Enable measurement functionality To add measurement functionalities add the dn_sketchingenhanced-measurement bundle to your app. diff --git a/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedController.ts b/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedController.ts index 3bc1fe5..cc5742d 100644 --- a/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedController.ts +++ b/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedController.ts @@ -336,6 +336,11 @@ export default class SketchingEnhancedController { const mapWidgetModel = this.mapWidgetModel; const map = mapWidgetModel.map; const layers = map.allLayers; + const sketchingEnhancedModel = this.sketchingEnhancedModel; + if(sketchingEnhancedModel.snappingGroupLayerId) { + const snappingGroupLayer = layers.find(layer => layer.id === sketchingEnhancedModel.snappingGroupLayerId); + snappingGroupLayer.visible = true; + } this.changeSnappingFeatureSources(layers, new Collection()); } @@ -343,6 +348,11 @@ export default class SketchingEnhancedController { const mapWidgetModel = this.mapWidgetModel; const map = mapWidgetModel.map; const layers = map.allLayers; + const sketchingEnhancedModel = this.sketchingEnhancedModel; + if(sketchingEnhancedModel.snappingGroupLayerId) { + const snappingGroupLayer = layers.find(layer => layer.id === sketchingEnhancedModel.snappingGroupLayerId); + snappingGroupLayer.visible = false; + } this.changeSnappingFeatureSources(new Collection(), layers); } diff --git a/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedModel.ts b/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedModel.ts index 036f6d0..e203a31 100644 --- a/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedModel.ts +++ b/src/main/js/bundles/dn_sketchingenhanced/SketchingEnhancedModel.ts @@ -40,6 +40,7 @@ interface SketchingEnhancedModelProps { snappingFeatureEnabled: boolean, snappingSelfEnabled: boolean, snappingFeatureSources: object[], + snappingGroupLayerId: string, pointSymbol: EsriSymbol, polylineSymbol: EsriSymbol, polygonSymbol: EsriSymbol, @@ -68,6 +69,7 @@ export default defineProperties