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

Remove cesium listeners when map is removed from DOM #2550

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions src/js/views/maps/CesiumWidgetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1662,6 +1662,12 @@ define([
);
}
},

/** Remove nav and mouse listeners when the view is closed */
onClose() {
this.removeMouseListeners();
this.removeNavigationListeners();
},
},
);

Expand Down
17 changes: 17 additions & 0 deletions src/js/views/maps/MapWidgetContainerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ define([
model: this.model,
});
mapWidget.render();
this.mapWidget = mapWidget;
},

/** Renders legend overlay. */
Expand All @@ -58,6 +59,7 @@ define([
});
legendContainerView.render();
this.$el.append(legendContainerView.el);
this.legendContainerView = legendContainerView;
},

/**
Expand All @@ -80,6 +82,7 @@ define([
pointModel: interactions.get("mousePosition"),
});
scaleBar.render();
this.scaleBar = scaleBar;
this.$el.append(scaleBar.el);

// If the interaction model or relevant sub-models are ever completely
Expand All @@ -95,6 +98,20 @@ define([
this.renderScaleBar,
);
},

/** Call the onClose method of each subview. */
onClose() {
const subViews = [
this.scaleBar,
this.legendContainerView,
this.mapWidget,
];
subViews.forEach((subView) => {
if (subView && typeof subView.onClose === "function") {
subView.onClose();
}
});
},
},
);

Expand Down
3 changes: 3 additions & 0 deletions src/js/views/search/CatalogSearchView.js
robyngit marked this conversation as resolved.
Show resolved Hide resolved
robyngit marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,9 @@ define([

// Remove the JSON-LD from the page
document.getElementById("jsonld")?.remove();

// Remove the map
this.mapView?.onClose();
} catch (e) {
console.error("Couldn't close search view. ", e);
robyngit marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
Loading