-
Notifications
You must be signed in to change notification settings - Fork 34
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
2611 visibility refresh #2627
2611 visibility refresh #2627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Alex-NRCan, @jolevesq, and @MatthewMuehlhauserNRCan)
packages/geoview-core/src/geo/map/map-viewer.ts
line 941 at r2 (raw file):
// Reload just the Geocore Layers instead of the entire map this.layer.reloadGeocoreLayers(); // this.reloadWithCurrentState();
Need to keep?
packages/geoview-core/src/geo/layer/layer.ts
line 589 at r2 (raw file):
/** * Refreshes GeoCore Layers * @returns {void} A promise which resolves when done refreshing
No longer a promise - update comment
Previously, DamonU2 (Damon Ulmi) wrote…
I wasn't sure if wanted that as a reference there that it was tested? It is an alternative to the current solution, although it would refresh the entire map and not just the GeoCore layers. Which one is better would depend on if there are layers in the map that aren't GeoCore layers since they would be reloaded as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @Alex-NRCan, @DamonU2, and @jolevesq)
packages/geoview-core/src/geo/layer/layer.ts
line 589 at r2 (raw file):
Previously, DamonU2 (Damon Ulmi) wrote…
No longer a promise - update comment
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, 1 of 2 files at r2, all commit messages.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @Alex-NRCan and @DamonU2)
packages/geoview-core/src/geo/map/map-viewer.ts
line 941 at r2 (raw file):
Previously, MatthewMuehlhauserNRCan wrote…
I wasn't sure if wanted that as a reference there that it was tested? It is an alternative to the current solution, although it would refresh the entire map and not just the GeoCore layers. Which one is better would depend on if there are layers in the map that aren't GeoCore layers since they would be reloaded as well.
If the relaod geocore works, we do not need the refresh state. It was another solution if the geocore switch as not working good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @Alex-NRCan and @DamonU2)
packages/geoview-core/src/geo/map/map-viewer.ts
line 941 at r2 (raw file):
Previously, jolevesq (Johann Levesque) wrote…
If the relaod geocore works, we do not need the refresh state. It was another solution if the geocore switch as not working good.
We can remove or put in comment that we reload instead of relaod with current state to not reload the whole map
Previously, jolevesq (Johann Levesque) wrote…
I did that. I removed the code and then added a little bit to the comment. I also combined the two comments there since it's such a small section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Alex-NRCan)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, all commit messages.
Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @DamonU2 and @MatthewMuehlhauserNRCan)
packages/geoview-core/src/geo/layer/layer.ts
line 660 at r5 (raw file):
} // Tried with onLayerLoaded, but didn't work as expected this.onLayerAdded(setLayerVisibility);
I was curious why the onLayerLoaded couldn't be used here and I think I've figured it out. 2 reasons:
1- There's an issue with how the LayerApi registers the onLayerLoaded event which we have an inbound fix for in another big PR. I'd suggest to cherry pick the fix right away. I'll create a small PR for it. It'll save a lot of code here and remove the need for a 'whenThisThen'.
2- In the layers classes (old and new), in their onLoaded() function (in which they raise their loaded event), there's code that sets the visibility right after triggering the event. I believe this is because one can't set the visibility of a layer until it's in an OpenLayers loaded state on the map (iirc I've read a comment about something like this when doing the layers refactoring). If we want our own 'layerLoaded' event to be raised after we've set the visibility flag, which I think makes sense, we should switch these 2 lines order:
Switching those 2 lines will set the visibility as expected, by default using the initialSettings, and only then emit the event, which only then will be caught by the code here, re-adjusting the visibility to what we actually want. Otherwise, the visibility of the layer would get changed here (when caught by the onLayerLoaded), then re-changed in the screenshotted function to its initialSettings, which isn't what we want in this case.
438c3cd
to
becadc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @DamonU2, @jolevesq, and @MatthewMuehlhauserNRCan)
packages/geoview-core/src/geo/layer/layer.ts
line 660 at r5 (raw file):
Previously, Alex-NRCan (Alex) wrote…
I was curious why the onLayerLoaded couldn't be used here and I think I've figured it out. 2 reasons:
1- There's an issue with how the LayerApi registers the onLayerLoaded event which we have an inbound fix for in another big PR. I'd suggest to cherry pick the fix right away. I'll create a small PR for it. It'll save a lot of code here and remove the need for a 'whenThisThen'.
2- In the layers classes (old and new), in their onLoaded() function (in which they raise their loaded event), there's code that sets the visibility right after triggering the event. I believe this is because one can't set the visibility of a layer until it's in an OpenLayers loaded state on the map (iirc I've read a comment about something like this when doing the layers refactoring). If we want our own 'layerLoaded' event to be raised after we've set the visibility flag, which I think makes sense, we should switch these 2 lines order:
Switching those 2 lines will set the visibility as expected, by default using the initialSettings, and only then emit the event, which only then will be caught by the code here, re-adjusting the visibility to what we actually want. Otherwise, the visibility of the layer would get changed here (when caught by the onLayerLoaded), then re-changed in the screenshotted function to its initialSettings, which isn't what we want in this case.
The hot fix PR is: #2634
After these 2 points addressed. I believe the code here becomes the following and the setLayerVisibility
function can be removed:
Code snippet:
// Catch the layer loaded event
this.onLayerLoaded((sender, event) => {
const { visible } = originalMapOrderedLayerInfo.filter((info) => info.layerPath === event.layerPath)[0];
event.layer?.setVisible(visible, path);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on @DamonU2, @jolevesq, and @MatthewMuehlhauserNRCan)
packages/geoview-core/src/geo/layer/layer.ts
line 660 at r5 (raw file):
Previously, Alex-NRCan (Alex) wrote…
The hot fix PR is: #2634
After these 2 points addressed. I believe the code here becomes the following and the
setLayerVisibility
function can be removed:
Rather, this, most likely:
Code snippet:
// Catch the layer loaded event
this.onLayerLoaded((sender, event) => {
const { visible } = originalMapOrderedLayerInfo.filter((info) => info.layerPath === event.layerPath)[0];
event.layer?.setVisible(visible, event.layerPath);
});
becadc6
to
a349716
Compare
Previously, Alex-NRCan (Alex) wrote…
I've switched to the onLayerLoaded after the rebase. It seems to work well and simplifies the code a lot. I did keep the callback function so I was able to remove the listener afterwards so they don't continue to build up. Although, they could potentially build up if someone continues to switch back and forth really fast. Maybe clearing the handlers array could make sure that doesn't happen, but I don't want to remove anything important that may also use this, although when I currently check, it is an empty array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @MatthewMuehlhauserNRCan)
31a6b10
to
894e770
Compare
ce0e3df
into
Canadian-Geospatial-Platform:develop
Description
Added functionality to update the visibility and remove layers as necessary on language change. Also cleaned up the setLanguage method in the map-viewer.ts.
Fixes # 2611
Type of change
How Has This Been Tested?
Turned off a layer and removed a child layer and then changed the language.
GeoCore Custom
Checklist:
I have made corresponding changes to the documentationI have added tests that prove my fix is effective or that my feature worksNew and existing unit tests pass locally with my changesThis change is