@regionerne/gis-komponent 0.0.113 → 0.0.114
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.
|
@@ -4341,10 +4341,14 @@ class ToolboxComponent {
|
|
|
4341
4341
|
// In order to add the distance to each segment of the distance measure feature, we need some extra handling like this.
|
|
4342
4342
|
this._distanceMeasureDraw.on('drawstart', (evt) => {
|
|
4343
4343
|
const sketch = evt.feature;
|
|
4344
|
+
this._featureHelper.setId(sketch);
|
|
4345
|
+
console.log("🚀 ~ ToolboxComponent ~ constructor ~ sketch:", sketch);
|
|
4344
4346
|
sketch.getGeometry().on('change', (geomEvt) => {
|
|
4345
4347
|
const geom = geomEvt.target;
|
|
4346
4348
|
const coords = geom.getCoordinates();
|
|
4347
|
-
|
|
4349
|
+
// Cleanup the labels for current item for each change.
|
|
4350
|
+
const featuresToRemove = this._distanceLabelSource.getFeatures().filter(f => f.get('_lineFeatureId') == sketch.getId());
|
|
4351
|
+
this._distanceLabelSource.removeFeatures(featuresToRemove);
|
|
4348
4352
|
let totalLength = 0;
|
|
4349
4353
|
for (let i = 0; i < coords.length - 1; i++) {
|
|
4350
4354
|
const c1 = coords[i];
|
|
@@ -4358,6 +4362,7 @@ class ToolboxComponent {
|
|
|
4358
4362
|
geometry: new Point$1(mid),
|
|
4359
4363
|
label: formatted
|
|
4360
4364
|
});
|
|
4365
|
+
labelFeature.set('_lineFeatureId', sketch.getId());
|
|
4361
4366
|
this._distanceLabelSource.addFeature(labelFeature);
|
|
4362
4367
|
}
|
|
4363
4368
|
// Add total length at the last point
|
|
@@ -4368,6 +4373,7 @@ class ToolboxComponent {
|
|
|
4368
4373
|
geometry: new Point$1(positionPoint),
|
|
4369
4374
|
label: `Total: ${formattedTotal}`
|
|
4370
4375
|
});
|
|
4376
|
+
totalFeature.set('_lineFeatureId', sketch.getId());
|
|
4371
4377
|
this._distanceLabelSource.addFeature(totalFeature);
|
|
4372
4378
|
}
|
|
4373
4379
|
});
|