From c79cd420a68a5517a096db1ee4177ab86a63bd32 Mon Sep 17 00:00:00 2001 From: ianguerin Date: Wed, 1 May 2024 11:21:15 -0700 Subject: [PATCH] Migrate home toolbar button to be a reset button that also resets layer visibility --- src/js/models/maps/assets/MapAsset.js | 2 +- src/js/views/maps/ToolbarView.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/js/models/maps/assets/MapAsset.js b/src/js/models/maps/assets/MapAsset.js index 4ec4d3ea13..e1b0b817a7 100644 --- a/src/js/models/maps/assets/MapAsset.js +++ b/src/js/models/maps/assets/MapAsset.js @@ -351,6 +351,7 @@ define([ } } + this.set("originalVisibility", this.get("visible")); this.setListeners(); } catch (e) { console.log("Error initializing a MapAsset model", e); @@ -393,7 +394,6 @@ define([ * @since 2.27.0 */ handleError: function () { - this.set("originalVisibility", this.get("visible")); this.set("visible", false); this.stopListening(this, "change:visible"); }, diff --git a/src/js/views/maps/ToolbarView.js b/src/js/views/maps/ToolbarView.js index f95a817c83..a198ce91ee 100644 --- a/src/js/views/maps/ToolbarView.js +++ b/src/js/views/maps/ToolbarView.js @@ -171,10 +171,15 @@ define( }, }, { - label: 'Home', - icon: 'home', + label: 'Reset', + icon: 'rotate-left', action: function (view, model) { model.flyHome(); + + // Reset the visibility of all layers. + for (const layer of model.getAllLayers()) { + layer.set("visible", layer.get('originalVisibility')); + } }, isVisible(model) { return model.get("showHomeButton");