Skip to content

Commit

Permalink
【fix】修复倾斜时scale不对的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
songyumeng committed Dec 23, 2023
1 parent 21da0cd commit 32d6899
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mapboxgl/web-map/control/scale/ScaleViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ export default class ScaleViewModel extends mapboxgl.Evented {
updateScale(map, options) {
const maxWidth = (options && options.maxWidth) || 100;

const centerPoint = map.project(map.crs.getLngLatCenter());
const left = map.unproject([centerPoint.x, centerPoint.y]);
let right = map.unproject([centerPoint.x + maxWidth, centerPoint.y]);
const y = map._container.clientHeight / 2;
const x = map._container.clientWidth / 2;
const left = map.unproject([x, y]);
let right = map.unproject([x + maxWidth, y]);
if (right.lng === left.lng) {
right = map.unproject([centerPoint.x - maxWidth, centerPoint.y]);
right = map.unproject([x - maxWidth, y]);
}
const maxMeters = this._getDistance(left, right);

Expand Down

0 comments on commit 32d6899

Please sign in to comment.