mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2026-08-03 09:21:40 -07:00
✨ Add removeOverlayByName function
This commit is contained in:
committed by
Matthieu Baumann
parent
cedea781a1
commit
c16309f670
@@ -1,5 +1,9 @@
|
||||
# Changelogs
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
* [feat] Add support for name removing in `removeOverlay` method
|
||||
|
||||
## 3.4.5-beta
|
||||
|
||||
* [feat] add `layerChanged` event when a layer is added or removed
|
||||
|
||||
+7
-4
@@ -1485,13 +1485,16 @@ export let Aladin = (function () {
|
||||
Aladin.prototype.removeLayers = Aladin.prototype.removeOverlays;
|
||||
|
||||
/**
|
||||
* Remove a overlay by its layer name
|
||||
*
|
||||
* Remove an overlay by its layer name
|
||||
*
|
||||
* @memberof Aladin
|
||||
* @param {string} layer
|
||||
* @param {string|Layer} layer - The name of the layer to remove or the layer object itself
|
||||
*/
|
||||
Aladin.prototype.removeOverlay = function (layer) {
|
||||
this.view.removeLayer(layer);
|
||||
if(layer instanceof String)
|
||||
this.view.removeOverlayByName(layer);
|
||||
else
|
||||
this.view.removeOverlay(layer);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+11
-2
@@ -2064,13 +2064,13 @@ export let View = (function () {
|
||||
this.requestRedraw();
|
||||
};
|
||||
|
||||
View.prototype.removeLayer = function (layer) {
|
||||
View.prototype.removeOverlay = function (layer) {
|
||||
let indexToDelete = this.allOverlayLayers.indexOf(layer);
|
||||
this.allOverlayLayers.splice(indexToDelete, 1);
|
||||
|
||||
if (layer.type == 'catalog' || layer.type == 'progressivecat') {
|
||||
indexToDelete = this.catalogs.indexOf(layer);
|
||||
|
||||
|
||||
this.catalogs.splice(indexToDelete, 1);
|
||||
|
||||
this.unselectObjects();
|
||||
@@ -2093,6 +2093,15 @@ export let View = (function () {
|
||||
this.requestRedraw();
|
||||
};
|
||||
|
||||
View.prototype.removeOverlayByName = function (layerName) {
|
||||
let layer = this.allOverlayLayers.find(l => l.name === layerName);
|
||||
if (!layer) {
|
||||
console.error(`Layer with name "${layerName}" not found.`);
|
||||
return;
|
||||
}
|
||||
this.removeOverlay(layer);
|
||||
};
|
||||
|
||||
View.prototype.addCatalog = function (catalog) {
|
||||
catalog.name = this.makeUniqLayerName(catalog.name);
|
||||
this.allOverlayLayers.push(catalog);
|
||||
|
||||
Reference in New Issue
Block a user