diff --git a/src/module_vmap/module/javascript/app/modules/Cadastre/cadastre.js b/src/module_vmap/module/javascript/app/modules/Cadastre/cadastre.js index 91a57bf08b978aba916e302d0bbed6393037e661..19adda6cfabf1f34a20541ed40c272173d2da31e 100644 --- a/src/module_vmap/module/javascript/app/modules/Cadastre/cadastre.js +++ b/src/module_vmap/module/javascript/app/modules/Cadastre/cadastre.js @@ -274,7 +274,7 @@ nsVmap.nsToolsManager.nsModules.Cadastre.prototype.cadastreController = function sString = oVmap.checkLink(sString); }else{ sString = oVmap.parseLink(sString, 'link'); - } + } return $sce.trustAsHtml(sString); }; }; @@ -1279,6 +1279,7 @@ nsVmap.nsToolsManager.nsModules.Cadastre.prototype.cadastreController.prototype. templateId: oVmap['properties']['cadastre']["fiche_urb"]['printtemplate_id'], mapId: oVmap['properties']['cadastre']["fiche_urb"]['map_id'], features: [feature], + recalcSize: true, featuresZoom: oVmap['properties']['cadastre']["fiche_urb"]['features_zoom'] }); }; @@ -2628,7 +2629,7 @@ nsVmap.nsToolsManager.nsModules.Cadastre.prototype.cadastreController.prototype. var data = response['data']['data']; - // Ajoute le type de voie + // Ajoute le type de voie for (var i = 0; i < data.length; i++) { if (goog.isDefAndNotNull(data[i]['L_NATURE_VOIE'])) { data[i]['NOM_VOIE'] = data[i]['L_NATURE_VOIE'] + ' ' + data[i]['DVOILIB']; 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 fd9550a4e7eef6b5fa9a5626cd32bdf50e029173..c438c6d1dd65631ad1a34c154de0253ca2bf0825 100644 --- a/src/module_vmap/module/javascript/app/vmap/tools/print.js +++ b/src/module_vmap/module/javascript/app/vmap/tools/print.js @@ -444,9 +444,11 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.setTemplate = fu this.$compile_(template)(this.$scope_); this_.template_ = template; - setTimeout(function () { - callback.call(this_, [template]); - }); + if (goog.isDefAndNotNull(callback)) { + setTimeout(function () { + callback.call(this_, [template]); + }); + } } }; @@ -626,6 +628,7 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.prepareAndLaunch * @param {number|undefined} opt_options.resolutionCoeff * @param {array<ol.Feature>|undefined} opt_options.features feature to zoom on * @param {number|undefined} opt_options.featuresZoom + * @param {boolean|undefined} opt_options.recalcSize true pour recalculer la taille au moment de l'impression (utilisé pour module cadastre) * @returns {number} 1 if all semms good * @export */ @@ -717,6 +720,17 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function var sFormat = response['data']['data'][0]['rt_format_id']; var sOrientation = response['data']['data'][0]['rt_orientation_id']; + // Cas d'utilisation de la fonction print sans passer par le forumlaire + if (opt_options.recalcSize === true || + !goog.isDefAndNotNull(this.printedMapSize_) || + !goog.isDefAndNotNull(this_.printedOverviewMapSize_)) { + this_.setTemplate({ + 'definition': response['data']['data'][0]['definition'] + }); + this_.printedMapSize_ = this_.getPrintedMapSize(this_.template_, '#map1', '#map_image'); + this_.printedOverviewMapSize_ = this_.getPrintedMapSize(this_.template_, '#map1', '#map_overview'); + } + var mapImageSize = this_.printedMapSize_.realSize; var overviewSize = this_.printedOverviewMapSize_.realSize; @@ -788,6 +802,8 @@ nsVmap.nsToolsManager.Print.prototype.printController.prototype.print = function $.notify('Impression réussie', 'success'); printWindow.location.href = response['data']['printtemplateservices']['image']; + delete this_.printedMapSize_; + delete this_.printedOverviewMapSize_; }, 'error': function (response) { console.error(response);