From d504ad917cb65982f0e89be87a77e74e49d9b846 Mon Sep 17 00:00:00 2001 From: Mauro Bartolomeoli Date: Fri, 10 Mar 2017 12:05:11 +0100 Subject: [PATCH] Fixed projection switching in WMS layers --- web/client/components/map/openlayers/Layer.jsx | 7 ++++--- .../components/map/openlayers/plugins/WMSLayer.js | 10 +++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/web/client/components/map/openlayers/Layer.jsx b/web/client/components/map/openlayers/Layer.jsx index 273ed399cd..3282da7cd9 100644 --- a/web/client/components/map/openlayers/Layer.jsx +++ b/web/client/components/map/openlayers/Layer.jsx @@ -92,7 +92,8 @@ const OpenlayersLayer = React.createClass({ } }, generateOpts(options, position, srs) { - return assign({}, options, position ? {zIndex: position, srs} : null, { + return assign({}, options, _.isNumber(position) ? {zIndex: position} : null, { + srs, onError: () => { this.props.onInvalid(this.props.type, options); } @@ -120,8 +121,8 @@ const OpenlayersLayer = React.createClass({ Layers.updateLayer( this.props.type, this.layer, - this.generateOpts(newProps.options, newProps.position, newProps.srs), - this.generateOpts(oldProps.options, oldProps.position, oldProps.srs), + this.generateOpts(newProps.options, newProps.position, newProps.projection), + this.generateOpts(oldProps.options, oldProps.position, oldProps.projection), this.props.map, this.props.mapId); }, diff --git a/web/client/components/map/openlayers/plugins/WMSLayer.js b/web/client/components/map/openlayers/plugins/WMSLayer.js index 50234a1a2c..6ceeca0737 100644 --- a/web/client/components/map/openlayers/plugins/WMSLayer.js +++ b/web/client/components/map/openlayers/plugins/WMSLayer.js @@ -98,7 +98,15 @@ Layers.registerType('wms', { } return found; }, false); - + if (oldOptions.srs !== newOptions.srs) { + const extent = ol.proj.get(CoordinatesUtils.normalizeSRS(newOptions.srs, newOptions.allowedSRS)).getExtent(); + layer.getSource().tileGrid = new ol.tilegrid.TileGrid({ + extent: extent, + resolutions: mapUtils.getResolutions(), + tileSize: newOptions.tileSize ? newOptions.tileSize : 256, + origin: newOptions.origin ? newOptions.origin : [extent[0], extent[1]] + }); + } if (changed) { layer.getSource().updateParams(objectAssign(newParams, newOptions.params)); }