diff --git a/contribs/gmf/src/controllers/AbstractAppController.js b/contribs/gmf/src/controllers/AbstractAppController.js index 4f99d4fe5495..76f214d52235 100644 --- a/contribs/gmf/src/controllers/AbstractAppController.js +++ b/contribs/gmf/src/controllers/AbstractAppController.js @@ -32,7 +32,6 @@ import olStyleFill from 'ol/style/Fill.js'; import olStyleStroke from 'ol/style/Stroke.js'; import olStyleStyle from 'ol/style/Style.js'; import {ThemeEventType} from 'gmf/theme/Manager.js'; -import {findThemeByName} from 'gmf/theme/Themes.js'; /** @@ -230,7 +229,8 @@ export function AbstractAppController(config, map, $scope, $injector) { this.gmfThemes_.loadThemes(roleId); if (evt.type !== 'ready') { - this.updateCurrentTheme_(previousThemeName); + const themeName = this.permalink_.defaultThemeNameFromFunctionalities(); + this.gmfThemeManager.updateCurrentTheme(themeName, previousThemeName); } this.setDefaultBackground_(null); this.updateHasEditableLayers_(); @@ -755,23 +755,6 @@ AbstractAppController.prototype.setDefaultBackground_ = function(theme) { }); }; -/** - * @param {string} fallbackThemeName fallback theme name. - * @private - */ -AbstractAppController.prototype.updateCurrentTheme_ = function(fallbackThemeName) { - this.gmfThemes_.getThemesObject().then((themes) => { - const themeName = this.permalink_.defaultThemeNameFromFunctionalities(); - if (themeName) { - const theme = findThemeByName(themes, /** @type {string} */ (themeName)); - if (theme) { - this.gmfThemeManager.addTheme(theme, true); - } - } else { - this.gmfThemeManager.setThemeName(fallbackThemeName); - } - }); -}; /** * @protected diff --git a/contribs/gmf/src/print/component.js b/contribs/gmf/src/print/component.js index a700248ba01f..8c7a8160f612 100644 --- a/contribs/gmf/src/print/component.js +++ b/contribs/gmf/src/print/component.js @@ -592,6 +592,10 @@ class Controller { * Init the controller */ $onInit() { + olEvents.listen(this.map.getView(), 'change:rotation', (event) => { + this.updateRotation_(Math.round(olMath.toDegrees(event.target.getRotation()))); + }); + // Clear the capabilities if the roles changes this.$scope_.$watch(() => this.gmfAuthenticationService_.getRolesIds().join(','), () => { this.gmfPrintState_.state = PrintStateEnum.CAPABILITIES_NOT_LOADED; @@ -867,11 +871,7 @@ class Controller { * @param {number} rotation The optional new rotation value in degrees. */ setRotation(rotation) { - this.rotation = olMath.clamp(rotation, -180, 180); - - // sync all the inputs - this.rotationInput_.val(this.rotation.toString()); - + this.updateRotation_(rotation); // Render the map to update the postcompose mask or rotate the map. if (this.rotateMask) { this.map.render(); @@ -880,6 +880,15 @@ class Controller { } } + /** + * Set the current rotation value. + * @param {number} rotation The optional new rotation value in degrees. + */ + updateRotation_(rotation) { + this.rotation = olMath.clamp(rotation, -180, 180); + // sync all the inputs + this.rotationInput_.val(this.rotation.toString()); + } /** * Calculate the angle and the sense of rotation between two lines. One from the diff --git a/contribs/gmf/src/theme/Manager.js b/contribs/gmf/src/theme/Manager.js index 3e3f82e9ddc5..24879c107bbe 100644 --- a/contribs/gmf/src/theme/Manager.js +++ b/contribs/gmf/src/theme/Manager.js @@ -1,6 +1,6 @@ import angular from 'angular'; import gmfLayertreeTreeManager from 'gmf/layertree/TreeManager.js'; -import gmfThemeThemes from 'gmf/theme/Themes.js'; +import gmfThemeThemes, {findThemeByName} from 'gmf/theme/Themes.js'; import ngeoStatemanagerService from 'ngeo/statemanager/Service.js'; @@ -115,6 +115,33 @@ ThemeManagerService.prototype.isLoading = function() { return !this.gmfThemes_.loaded; }; + +/** + * @param {string} themeName wanted theme name. + * @param {string} fallbackThemeName fallback theme name. + * @export + */ +ThemeManagerService.prototype.updateCurrentTheme = function(themeName, fallbackThemeName) { + this.gmfThemes_.getThemesObject().then((themes) => { + if (!themeName && this.modeFlush) { + // In flush mode load current theme private groups + const fallbackTheme = findThemeByName(themes, fallbackThemeName); + if (fallbackTheme) { + this.gmfTreeManager_.addFirstLevelGroups(fallbackTheme.children, false, false); + } + } + if (themeName) { + const theme = findThemeByName(themes, themeName); + if (theme) { + this.addTheme(theme, true); + } + } else { + this.setThemeName(fallbackThemeName); + } + }); +}; + + /** * @param {string} name The new theme name. * @param {boolean=} opt_silent Don't emit a theme change event, default is false.