From 38bafafa7772f5067948791fef197136e37ff5b4 Mon Sep 17 00:00:00 2001 From: Armand Bahi <armand.bahi@veremes.com> Date: Mon, 29 Oct 2018 15:05:33 +0100 Subject: [PATCH] Increase the WMS symbols size to match resolution --- vas/util/printserver/client/map/map.js | 34 ++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/vas/util/printserver/client/map/map.js b/vas/util/printserver/client/map/map.js index 2a870d9a..d6dcd882 100755 --- a/vas/util/printserver/client/map/map.js +++ b/vas/util/printserver/client/map/map.js @@ -7,7 +7,7 @@ PrintMap = function (opt_options) { var this_ = this; - + this.mapSize = [document.getElementById('map').offsetWidth, document.getElementById('map').offsetHeight]; this.tileSize = (isDef(window.oProperties.print.tile_size) && window.oProperties.print.features_zoom >= 0) ? window.oProperties.print.tile_size : 2048; @@ -29,7 +29,7 @@ PrintMap = function (opt_options) { this.mapJsonParser = new MapJSON({ 'properties': window.oProperties }); - + this.view = this.mapJsonParser.getViewFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] @@ -39,13 +39,13 @@ PrintMap = function (opt_options) { this.extent = this.getExtent(opt_options); - this.tileGrid = this.getTileGridFromDefinition(this.tileSize); - + this.tileGrid = this.getTileGridFromDefinition(this.tileSize); + this.layers = this.mapJsonParser.getLayersFromDef(this.mapDefinition, { 'size': this.mapSize, 'tileSize': [this.tileSize, this.tileSize] }); - + this.map = this.setMap(this.layers, this.view); this.featuresOverlay = this.setFeaturesOverlay(this.map); @@ -63,6 +63,9 @@ PrintMap = function (opt_options) { // Supprime tous les controls par défaut this.removeMapControls(); + // Taille des icones en fonction de la résolution demandée + this.setMapSymbolsResolution(this.map, this.resolutionCoeff) + // Si aucune étendue a été donnée et que seul un point a été donné, alors zoom sur this.defaultScale if (!isDef(opt_options.extent) && !isDef(this.features)) { if (this.features.length === 1 && this.features[0].getGeometry().getType() === 'Point') { @@ -310,7 +313,7 @@ PrintMap.prototype.getFeaturesFromEWKT = function (aEWKTFeatures) { }; /** - * Return true if EWKTGeom is an EWKT geometry + * Return true if EWKTGeom is an EWKT geometry * @param {string} EWKTGeom * @returns {boolean} */ @@ -367,4 +370,21 @@ PrintMap.prototype.getGeomFromEWKT = function (EWKTGeom, proj) { return null; } -}; \ No newline at end of file +}; + +/** + * For WMS layers set MAP.RESOLUTION and MAP.DEFRESOLUTION to rise the symbols size + * + * @param {object} olMap + * @param {integer} resolutionCoeff + */ +PrintMap.prototype.setMapSymbolsResolution = function (olMap, resolutionCoeff) { + + var newRes = resolutionCoeff * 72; + var aLayers = olMap.getLayers().getArray(); + for (var i = 0; i < aLayers.length; i++) { + if (aLayers[i].get('type') === 'imagewms' || aLayers[i].get('type') === 'tilewms') { + aLayers[i].getSource().updateParams({'MAP.RESOLUTION': newRes, 'MAP.DEFRESOLUTION': 72}); + } + } +} -- GitLab