-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Popup click changing routes results in NG0953 #193
Comments
I stumbled across the same error when using
Tried to create an example of all that: MapTest Stackblitz EDIT: |
Looking at the MapService addLayer code, it looks like when removing a layer there might be a need to unregister all the registrations that were made when the latter was added. |
hey there. Thanks for the fast response. I just digged into the code a bit and if i am not totally mistaken i need the listener function itself (reference) which gets registered on the mapInstance.on call, to unregister it later on to call mapInstance.off within removeLayer. So we have to store it somewhere. This should then also apply to all other mapInstance.on calls that are not global map related ? i am not so familiar with this library code. so i will just get into it more deeper and hopefully can come up with a solution or maybe a good suggestion. Wish i could remove all events from the mapInstance with just the eventTypeName and the layer ID, but as far is i know that is not possible. |
I tend to think you got it correctly. |
So i played around and testet this with only the layerMouseMove event and stored the function within a mapService variable. When i call the off function for the mapInstance within removeLayer with the function reference, no error gets thrown. Now, i think, it would just be a matter of where to store the listener functions |
i got another confession to make. The base problem i stumbled across all this, is because i edit the layers paint and layout properties. Now i realized, that when i update layout or paint, the properties that are removed from previousValue to currentValue are ignored, because setAllLayerPaintProperty and setAllLayerLayoutProperty are only handling the current available keys. i am on it =P |
I have the same issue now with one of my popups in my latest version. |
I see that I'll create a PR to bring it back unless @n-elhk can explain why it was removed and how to solve the current issue at hand. ngOnDestroy() {
if (this.popupInstance) {
if (this.lngLat || this.feature) {
this.mapService.removePopupFromMap(this.popupInstance);
} else if (this.marker && this.marker.markerInstance) {
this.mapService.removePopupFromMarker(this.marker.markerInstance);
}
}
this.popupInstance = undefined;
} |
My mistake, this method was just renamed and is used from destroyRef now... |
I think I was able to create a minimal reproduction of my scenario: |
Interestingly enough, calling the same method from |
I've checked the situation in a previous version (17.4.3). |
I havent figured out yet, about the removing and readding layers with the same id problem (have not got time enought yet). But i just tried reset layout and paint properties if some of them got removed. will help to investigate more here. but i sadly dont know when to take the time. |
I investigated and found something surprising: destroyRef.ondestroy and ngOndestroy are not triggered at the same time. It seems to me that the ngOndestroy life cycle is called when all its children have been destroyed. whereas ondestroy is called as soon as the component is destroyed, regardless of the state of its children. |
I've observed this too, but I don't think this is the problem in this case. |
@n-elhk do you remember why you changed the value of the second parameter below from
Was it the same warning in the console? I'm trying to figure out if and when a close event should be emitted if the popup is destroyed vs simply closed... |
I have an application where a Popup display data and uses
RouterLink
to change the route on click.When the route changes the popup is closed which emits the
popupClose
output. However, the component is already destroyed. This breaks the navigation resulting in a white screen.I will try to add an example for this
The text was updated successfully, but these errors were encountered: