Skip to content

Commit

Permalink
Fixed projection switching in WMS layers (#1534)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto authored Mar 10, 2017
1 parent 679ca32 commit 7889686
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 4 additions & 3 deletions web/client/components/map/openlayers/Layer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
},
Expand Down
10 changes: 9 additions & 1 deletion web/client/components/map/openlayers/plugins/WMSLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 7889686

Please sign in to comment.