mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 15:49:18 -08:00
fix: remove overlay by name
This commit is contained in:
@@ -1482,10 +1482,11 @@ export let Aladin = (function () {
|
||||
* @param {string|Overlay} overlay - The name of the overlay to remove or the overlay object itself
|
||||
*/
|
||||
Aladin.prototype.removeOverlay = function (overlay) {
|
||||
if(overlay instanceof String)
|
||||
if(typeof overlay === 'string' || overlay instanceof String) {
|
||||
this.view.removeOverlayByName(overlay);
|
||||
else
|
||||
} else {
|
||||
this.view.removeOverlay(overlay);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2060,6 +2060,11 @@ export let View = (function () {
|
||||
|
||||
View.prototype.removeOverlay = function (overlay) {
|
||||
let indexToDelete = this.allOverlayLayers.indexOf(overlay);
|
||||
if (indexToDelete === -1) {
|
||||
// overlay not found
|
||||
return;
|
||||
}
|
||||
|
||||
this.allOverlayLayers.splice(indexToDelete, 1);
|
||||
|
||||
if (overlay.type == 'catalog' || overlay.type == 'progressivecat') {
|
||||
@@ -2088,9 +2093,10 @@ export let View = (function () {
|
||||
};
|
||||
|
||||
View.prototype.removeOverlayByName = function (overlayName) {
|
||||
let overlay = this.allOverlayLayers.find(l => l.name === overlayName);
|
||||
let overlay = this.allOverlayLayers.find(o => o.name === overlayName);
|
||||
console.log("jkj", overlay)
|
||||
if (!overlay) {
|
||||
console.error(`Layer with name "${overlayName}" not found.`);
|
||||
console.error(`Overlay "${overlayName}" not found.`);
|
||||
return;
|
||||
}
|
||||
this.removeOverlay(overlay);
|
||||
|
||||
Reference in New Issue
Block a user