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

#9018: Dashboard - Zoom in/out on maps connected to a 3D map #10460

Open
wants to merge 2 commits 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
10 changes: 5 additions & 5 deletions web/client/components/map/cesium/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class CesiumMap extends React.Component {
return false;
}
// avoid errors like 44.40641479 !== 44.40641478999999
return a.toFixed(12) - b.toFixed(12) <= 0.000000000001;
return Math.abs(a.toFixed(12) - b.toFixed(12)) <= 0.000000000001; // using Math.abs to include negative values
};

// there are some transition cases where the center is not defined
Expand All @@ -497,15 +497,15 @@ class CesiumMap extends React.Component {

const centerIsUpdate = !isNearlyEqual(newProps.center.x, currentCenter.longitude) ||
!isNearlyEqual(newProps.center.y, currentCenter.latitude);
const zoomChanged = newProps.zoom !== currentZoom;
const zoomChanged = Math.round(newProps.zoom) !== Math.round(currentZoom); // round both to ignore the small tolerance due to calc zoom from hight

// Do the change at the same time, to avoid glitches
if (centerIsUpdate || zoomChanged) {
const position = {
destination: Cesium.Cartesian3.fromDegrees(
newProps.viewerOptions?.cameraPosition?.longitude ?? newProps.center.x,
newProps.viewerOptions?.cameraPosition?.latitude ?? newProps.center.y,
newProps.viewerOptions?.cameraPosition?.height ?? this.getHeightFromZoom(newProps.zoom ?? 0)
newProps.mapStateSource !== this.props.id ? newProps?.center?.x ?? newProps.viewerOptions?.cameraPosition?.longitude : newProps.viewerOptions?.cameraPosition?.longitude ?? newProps.center.x,
newProps.mapStateSource !== this.props.id ? newProps?.center?.y ?? newProps.viewerOptions?.cameraPosition?.latitude : newProps.viewerOptions?.cameraPosition?.latitude ?? newProps.center.y,
newProps.mapStateSource !== this.props.id ? this.getHeightFromZoom(newProps.zoom ?? 0) ?? newProps.viewerOptions?.cameraPosition?.height : newProps.viewerOptions?.cameraPosition?.height ?? this.getHeightFromZoom(newProps.zoom ?? 0)
Comment on lines -506 to +508
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore this to the previous arguments, if we want to propertly control the camera direction we will need to include the viewerOptions property to the widgets dependecies.

),
orientation: newProps.viewerOptions?.orientation
};
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/map/openlayers/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class OpenlayersMap extends React.Component {
let center = 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) {
if (Math.round(newProps.zoom) !== Math.round(this.props.zoom)) {
view.setZoom(Math.round(newProps.zoom));
}
if (newProps.bbox && newProps.bbox.rotation !== undefined || this.bbox && this.bbox.rotation !== undefined && newProps.bbox.rotation !== this.props.bbox.rotation) {
Expand Down
Loading