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(landing): Fix the zoom to extend by using maplibre to adjust AntiMeridian. BM-1155 #3384

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
41 changes: 20 additions & 21 deletions packages/landing/src/components/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,26 @@ export class Basemaps extends Component<unknown, { isLayerSwitcherEnabled: boole
};

updateBounds = (bounds: maplibregl.LngLatBoundsLike): void => {
if (Config.map.tileMatrix !== GoogleTms) {
// Transform bounds to current tileMatrix
const lngLatBounds: maplibregl.LngLatBounds = maplibre.LngLatBounds.convert(bounds);
const upperLeft = lngLatBounds.getNorthEast();
const lowerRight = lngLatBounds.getSouthWest();
const zoom = this.map.getZoom();
const upperLeftLocation = locationTransform(
{ lat: upperLeft.lat, lon: upperLeft.lng, zoom },
Config.map.tileMatrix,
GoogleTms,
);
const lowerRightLocation = locationTransform(
{ lat: lowerRight.lat, lon: lowerRight.lng, zoom },
Config.map.tileMatrix,
GoogleTms,
);
bounds = [
[upperLeftLocation.lon, upperLeftLocation.lat],
[lowerRightLocation.lon, lowerRightLocation.lat],
];
}
// Transform bounds to current tileMatrix
const lngLatBounds: maplibregl.LngLatBounds = maplibre.LngLatBounds.convert(bounds);
const upperLeft = lngLatBounds.getNorthEast();
const lowerRight = lngLatBounds.getSouthWest();
const zoom = this.map.getZoom();
const upperLeftLocation = locationTransform(
{ lat: upperLeft.lat, lon: upperLeft.lng, zoom },
Config.map.tileMatrix,
GoogleTms,
);
const lowerRightLocation = locationTransform(
{ lat: lowerRight.lat, lon: lowerRight.lng, zoom },
Config.map.tileMatrix,
GoogleTms,
);
bounds = [
[upperLeftLocation.lon, upperLeftLocation.lat],
[lowerRightLocation.lon, lowerRightLocation.lat],
];

this.map.fitBounds(bounds);
};

Expand Down
Loading