Skip to content

Commit

Permalink
Fix measure behaviour handling of adding/clearing features. #196
Browse files Browse the repository at this point in the history
Fixes #195
  • Loading branch information
symbioquine committed May 11, 2023
1 parent 5c0678b commit 6176792
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix #195 measure behaviour handling of adding/clearing features. #196

## [v2.2.0] - 2023-05-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/behavior/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ export default {
createMeasure(feature);
});

// Remove any stale measurements if the drawing layer gets cleared
layer.getSource().on('clear', () => {
stopMeasure();
});

// Add measurements for features which are added directly to the drawing layer
layer.getSource().on('addfeature', (evt) => {
startMeasure(evt.feature);
});

// If the instance has an Edit control, attach listeners to the map
// interactions so that we can apply measurements to the features.
if (instance.edit) {
Expand Down

0 comments on commit 6176792

Please sign in to comment.