From a69ce868492319a9ce35194fdc61e8f00fd37976 Mon Sep 17 00:00:00 2001 From: Pekka Helesuo Date: Tue, 26 Nov 2024 10:24:49 +0200 Subject: [PATCH] fix storing the map rotation in publisher --- .../mapping/maprotator/publisher/MapRotator.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bundles/mapping/maprotator/publisher/MapRotator.js b/bundles/mapping/maprotator/publisher/MapRotator.js index 9aea7e5575..4691173062 100755 --- a/bundles/mapping/maprotator/publisher/MapRotator.js +++ b/bundles/mapping/maprotator/publisher/MapRotator.js @@ -21,12 +21,27 @@ class MapRotatorTool extends AbstractPublisherTool { } // saved configuration -> restore. - const conf = data.configuration[this.bundleName].conf || {}; + const bundleData = data.configuration[this.bundleName]; + const conf = bundleData?.conf || {}; this.handler.init(conf); this.storePluginConf(conf); + this.storePluginState(bundleData?.state || {}); this.setEnabled(true); } + storePluginState (state) { + this.state.pluginState = state || {}; + } + + setEnabled (enabled) { + super.setEnabled(enabled); + if (enabled && this.state.pluginState?.degrees) { + this.getPlugin().setRotation(this.state.pluginState?.degrees); + } else { + this.getMapmodule().getMap().getView().setRotation(0); + } + } + isDisplayed () { // shouldn't be shown if bundle is not started // otherwise results in js errors