Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix measure behaviour handling of adding/clearing features #196

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading