Skip to content

Commit

Permalink
Fixed reprojection of center in OpenLayers map component (#1635)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed Mar 23, 2017
1 parent 2f36b06 commit c8938c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ var OpenlayersMap = React.createClass({
newProps.center.x === currentCenter.x;

if (!centerIsUpdated) {
let center = ol.proj.transform([newProps.center.x, newProps.center.y], 'EPSG:4326', newProps.projection);
view.setCenter(center);
// let center = ol.proj.transform([newProps.center.x, newProps.center.y], 'EPSG:4326', newProps.projection);
let center = CoordinatesUtils.reproject({x: newProps.center.x, y: newProps.center.y}, 'EPSG:4326', newProps.projection, true);
view.setCenter([center.x, center.y]);
}
if (Math.round(newProps.zoom) !== this.props.zoom) {
view.setZoom(Math.round(newProps.zoom));
Expand All @@ -331,7 +332,8 @@ var OpenlayersMap = React.createClass({
}
},
normalizeCenter: function(center) {
return ol.proj.transform(center, this.props.projection, 'EPSG:4326');
let c = CoordinatesUtils.reproject({x: center[0], y: center[1]}, this.props.projection, 'EPSG:4326', true);
return [c.x, c.y];
},
setMousePointer(pointer) {
if (this.map) {
Expand Down

0 comments on commit c8938c7

Please sign in to comment.