diff --git a/src/module_vmap/module/javascript/app/vmap/tools/print.js b/src/module_vmap/module/javascript/app/vmap/tools/print.js index f7f2d63ddf1ee33e3a17f4b243bace8d9cadc869..efc99e6add1af7135b89c9210efd195df339902c 100644 --- a/src/module_vmap/module/javascript/app/vmap/tools/print.js +++ b/src/module_vmap/module/javascript/app/vmap/tools/print.js @@ -363,7 +363,10 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.loadModelParmas2 oVmap.log('nsVmap.nsToolsManager.Print.printController.loadModelParmas2'); // Récupère la taille de la carte this.printedMapSize_ ainsi que le coefficient this.resizeCoeff_ - this.setPrintedMapSize(this.template_); + oPrintMapSize = this.getPrintedMapSize(this.template_); + + this.printedMapSize_ = oPrintMapSize.printedMapSize; + this.resizeCoeff_ = oPrintMapSize.resizeCoeff; // Pré-rempli le champ "Résolution" this['resolution'] = this.resizeCoeff_; @@ -376,17 +379,20 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.loadModelParmas2 this.printBox_.show(); if(this.$scope_["$root"]["compare_enabled"]){ - if(this.setPrintedMapSize(this.template_,"#map1Compare","#map_image_compare") !== 0){ - // Pré-rempli le champ "Résolution" - this['resolutionCompare'] = this.resizeCoeff_; - - // Ajuste l'échelle avec le niveau de détail - this['currentScaleCompare'] = oVmap.getMapCompare().getPrettyScale(oVmap.getMapCompare().getScale() / this.resizeCoeff_); - - // Dessine un carré d'impression à chaque mouvement de la carte - this.printBoxCompare_.setSize(this.printedMapSize_); - this.printBoxCompare_.show(); - } + this.oComparePrintMapSize = this.getPrintedMapSize(this.template_,"#map1Compare","#map_image_compare"); + if(this.oComparePrintMapSize !== 0){ + // Pré-rempli le champ "Résolution" + this['resolutionCompare'] = this.oComparePrintMapSize.resizeCoeff; + + // Ajuste l'échelle avec le niveau de détail + this['currentScaleCompare'] = oVmap.getMapCompare().getPrettyScale(oVmap.getMapCompare().getScale() / this.oComparePrintMapSize.resizeCoeff); + + // Dessine un carré d'impression à chaque mouvement de la carte + this.printBoxCompare_.setSize(this.oComparePrintMapSize.printedMapSize); + this.printBoxCompare_.show(); + } else { + this.printBoxCompare_.hide(); + } } }; @@ -423,11 +429,15 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.setTemplate = fu }; /** - * Set this.printedMapSize_ and this.resizeCoeff_ - * @param {object} template + * Get the print map size and resolution coeff + * + * @param {type} template + * @param {type} sElementMapId + * @param {type} sPrintId + * @return {object} */ -nsVmap.nsToolsManager.Print.prototype.printController.prototype.setPrintedMapSize = function (template, sElementMapId, sPrintId) { - oVmap.log('nsVmap.nsToolsManager.Print.printController.setPrintedMapSize'); +nsVmap.nsToolsManager.Print.prototype.printController.prototype.getPrintedMapSize = function (template, sElementMapId, sPrintId) { + oVmap.log('nsVmap.nsToolsManager.Print.printController.getPrintedMapSize'); sPrintId = (goog.isDefAndNotNull(sPrintId)) ? sPrintId : '#map_image'; sElementMapId = (goog.isDefAndNotNull(sElementMapId)) ? sElementMapId : '#map1'; @@ -451,16 +461,19 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.setPrintedMapSiz $(template).remove(); // Vérifie si la taille de la carte est suppérieur à la taille de l'écran - this.resizeCoeff_ = 1; + var resizeCoeff = 1; var tmpWidth = angular.copy(mapWidth); var tmpHeight = angular.copy(mapHeight); while (mapWidth > ($(sElementMapId).width()) || mapHeight > ($(sElementMapId).height())) { - this.resizeCoeff_++; - mapWidth = tmpWidth / this.resizeCoeff_; - mapHeight = tmpHeight / this.resizeCoeff_; + resizeCoeff++; + mapWidth = tmpWidth / resizeCoeff; + mapHeight = tmpHeight / resizeCoeff; } - this.printedMapSize_ = [mapWidth, mapHeight]; + return { + printedMapSize: [mapWidth, mapHeight], + resizeCoeff: resizeCoeff + } }; /** @@ -562,12 +575,13 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.prepareAndLaunch // récupération des infos pour la carte de comparaison si le mode comparaison est actif if(this.$scope_['$root']["compare_enabled"]){ - // Enregistre l'échelle actuelle - this.currentScaleCompare_ = oVmap.getMapCompare().getScale({ - 'pretty': true - }); - oPrintOptions.extentCompare = this.printBoxCompare_.getExtent(); - //oPrintOptions['mapIdCompare'] = this.printBoxCompare_.getExtent(); + if(this.oComparePrintMapSize !== 0){ + // Enregistre l'échelle actuelle + this.currentScaleCompare_ = oVmap.getMapCompare().getScale({ + 'pretty': true + }); + oPrintOptions.extentCompare = this.printBoxCompare_.getExtent(); + } } // Lance l'impression