diff --git a/examples/al-event-listeners.html b/examples/al-event-listeners.html
index aed24c0d..211863f0 100644
--- a/examples/al-event-listeners.html
+++ b/examples/al-event-listeners.html
@@ -60,8 +60,8 @@
console.log(proj)
});
- aladin.on('layerChanged', function(imageLayer, layer){
- console.log(imageLayer, layer)
+ aladin.on('layerChanged', function(imageLayer, layer, state){
+ console.log(imageLayer, layer, state)
});
cat.sources[0].actionClicked();
diff --git a/src/js/Aladin.js b/src/js/Aladin.js
index 1c268634..4f0091ae 100644
--- a/src/js/Aladin.js
+++ b/src/js/Aladin.js
@@ -286,6 +286,17 @@ export let Aladin = (function () {
const self = this;
+ ALEvent.HIPS_LAYER_ADDED.listenedBy(aladinDiv, (imageLayer) => {
+ this.callbacksByEventName["layerChanged"] &&
+ this.callbacksByEventName["layerChanged"](imageLayer.detail.layer, imageLayer.detail.layer.layer, "ADDED");
+ });
+
+ ALEvent.HIPS_LAYER_REMOVED.listenedBy(aladinDiv, (imageLayer) => {
+ console.log(imageLayer)
+ this.callbacksByEventName["layerChanged"] &&
+ this.callbacksByEventName["layerChanged"](imageLayer.detail.layer, imageLayer.detail.layer.layer, "REMOVED");
+ });
+
// if not options was set, try to retrieve them from the query string
if (requestedOptions === undefined) {
requestedOptions = this.getOptionsFromQueryString();
diff --git a/src/js/View.js b/src/js/View.js
index cda4438d..5f33b833 100644
--- a/src/js/View.js
+++ b/src/js/View.js
@@ -1760,9 +1760,6 @@ export let View = (function () {
self.renameLayer(this.overlayLayers[0], "base");
}
}
-
- const layerChangedFn = this.aladin.callbacksByEventName["layerChanged"];
- (typeof layerChangedFn === "function") && layerChangedFn(imageLayer, layer);
})
}