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

Refactor reference image layer state saving/loading #51

Open
mstone121 opened this issue Aug 30, 2022 · 2 comments
Open

Refactor reference image layer state saving/loading #51

mstone121 opened this issue Aug 30, 2022 · 2 comments
Labels
polish Ideas for improvement by Azavea

Comments

@mstone121
Copy link
Contributor

mstone121 commented Aug 30, 2022

Overview

The current implementation of the reference layer does not reload from state each time it's updated. This is because the layer would become unselected each time it changed (despite supplying the selected: true prop in the initialization options).

It also cannot load the transparency and outline modes from state. This is because there is no way to set these options while initializing the layer. My attempts to set them after the layer is initialized have been unsuccessful because the function calls which enable these properties can only be called after certain initialization steps are finished. To my knowledge, there are no events that are fired after the initialization has finished.

Describe the solution you'd like

Two things are needed to solve these problems and it's likely their solutions are related:

  • Find a way to specify transparency and outline when initializing the layer
  • Find a cleaner way to hook into image layer updates

If these two solutions are implemented, then the variables from state can be included in the ReferenceLayer's useEffect hook.

Additional Context

Regarding the image updates, listening for the edit event covers any update of the edit handles. The dragend event which is added by L.DistortableImage.Edit.fix.js does a good job of hooking into drag events of the entire image. I created a PR on the L.DistortableImage repo to implement this: publiclab/Leaflet.DistortableImage#1014

The refresh event, which is used to track mode and transparency/outline changes, however, will not work with these proposed changes. This is because the event is fired when the layer is initialized and will cause an render loop.

@rajadain
Copy link
Contributor

rajadain commented Nov 8, 2022

Does this still apply?

@mstone121
Copy link
Contributor Author

Yes, as of now, reference layers still don't respond to state changes (besides visibility).

@rajadain rajadain added the polish Ideas for improvement by Azavea label Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
polish Ideas for improvement by Azavea
Projects
None yet
Development

No branches or pull requests

2 participants