Skip to content

Commit

Permalink
Add snappingGroupLayerId
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasstein committed Dec 2, 2023
1 parent f2c015e commit 4f6a221
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/js/apps/sample/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"snappingEnabled": true,
"snappingSelfEnabled": true,
"snappingFeatureEnabled": true,
"snappingGroupLayerId": "snapping_layer",
"pointSymbol": {
"type": "simple-marker",
"style": "circle",
Expand Down Expand Up @@ -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",
Expand All @@ -265,6 +291,8 @@
{
"id": "grenzen",
"title": "Grenzen",
"type": "GROUP",
"visible": false,
"layers": [
{
"id": "grenzen_0",
Expand Down
50 changes: 50 additions & 0 deletions src/main/js/bundles/dn_sketchingenhanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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. |
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,23 @@ 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());
}

removeSnappingFeatureSources(): void {
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface SketchingEnhancedModelProps {
snappingFeatureEnabled: boolean,
snappingSelfEnabled: boolean,
snappingFeatureSources: object[],
snappingGroupLayerId: string,
pointSymbol: EsriSymbol,
polylineSymbol: EsriSymbol,
polygonSymbol: EsriSymbol,
Expand Down Expand Up @@ -68,6 +69,7 @@ export default defineProperties<SketchingEnhancedModel, SketchingEnhancedModelPr
snappingFeatureEnabled: true,
snappingSelfEnabled: true,
snappingFeatureSources: [],
snappingGroupLayer: null,
pointSymbol: {},
polylineSymbol: {},
polygonSymbol: {},
Expand Down
1 change: 1 addition & 0 deletions src/main/js/bundles/dn_sketchingenhanced/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"snappingEnabled": true,
"snappingSelfEnabled": true,
"snappingFeatureEnabled": true,
"snappingGroupLayer": null,
"pointSymbol": {
"type": "simple-marker",
"style": "circle",
Expand Down

0 comments on commit 4f6a221

Please sign in to comment.