Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10807 load map error and correctly update view when sharing a map #10847

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/client/components/map/cesium/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ class CesiumMap extends React.Component {
return false;
}
// avoid errors like 44.40641479 !== 44.40641478999999
return a.toFixed(12) - b.toFixed(12) <= 0.000000000001;
// using abs because the difference can be negative, creating a false positive
return Math.abs(a.toFixed(12) - b.toFixed(12)) <= 0.000000000001;
};

// there are some transition cases where the center is not defined
Expand Down
4 changes: 2 additions & 2 deletions web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,8 @@ class OpenlayersMap extends React.Component {
if (a === undefined || b === undefined) {
return false;
}
return a.toFixed(8) - b.toFixed(8) <= 0.00000001;
// using abs because the difference can be negative, creating a false positive
return Math.abs(a.toFixed(8) - b.toFixed(8)) <= 0.00000001;
};

_updateMapPositionFromNewProps = (newProps) => {
Expand All @@ -553,7 +554,6 @@ class OpenlayersMap extends React.Component {
this.isNearlyEqual(newProps.center.x, currentCenter.x);

if (!centerIsUpdated) {
// let center = ol.proj.transform([newProps.center.x, newProps.center.y], 'EPSG:4326', newProps.projection);
let center = reproject({ x: newProps.center.x, y: newProps.center.y }, 'EPSG:4326', newProps.projection, true);
view.setCenter([center.x, center.y]);
}
Expand Down