Skip to content

Commit

Permalink
Merge pull request #59 from azavea/ms/save-initial-reference-image-lo…
Browse files Browse the repository at this point in the history
…cation

Save layer corners on layer remove
  • Loading branch information
mstone121 authored Sep 7, 2022
2 parents caa3407 + 76eb0b1 commit d3daef9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix react-remove-scroll-bar warning [#29](https://github.com/azavea/iow-boundary-tool/pull/29)
- Don't move reference image when panning map [#59](https://github.com/azavea/iow-boundary-tool/pull/59)

### Deprecated

Expand Down
21 changes: 21 additions & 0 deletions src/app/src/components/Layers/ReferenceImageLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ function ReferenceImageLayer() {
layer.on('dragend', updateImageHandler);
layer.on('refresh', updateImageHandler);

/**
* This is handler is added to save the default position of the
* reference image. It uses the remove event because the corners
* don't always exist on the add event. Also, corners might not
* be set for some remove events, so their their existence is
* verified before dispatching an update,
*/
if (!corners) {
layer.on('remove', ({ target: layer }) => {
if (layer._corners) {
dispatch(
updateReferenceImage({
corners: layer._corners.map(
convertCornerToStateFormat
),
})
);
}
});
}

return layer;
},
// TODO: Figure out how to prevent deselect on re-render
Expand Down

0 comments on commit d3daef9

Please sign in to comment.