Skip to content

Commit

Permalink
fix(map): fix roam after projection
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Jan 10, 2022
1 parent eb515b3 commit d9ba7c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/action/roamHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export function updateCenterAndZoom(
const center = view.getCenter();
let zoom = payload.zoom;

const point = view.dataToPoint(center);
const point = (view as Geo).projectedToPoint
? (view as Geo).projectedToPoint(center)
: view.dataToPoint(center);

if (payload.dx != null && payload.dy != null) {
point[0] -= payload.dx;
Expand Down
14 changes: 9 additions & 5 deletions src/coord/geo/Geo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ class Geo extends View {
}
if (data) {
const projection = this.projection;
return super.dataToPoint(
projection ? projection.project(data) : data,
noRoam, out
);
if (projection) {
data = projection.project(data);
}
return this.projectedToPoint(data);
}
}

pointToData(point: number[]) {
const projection = this.projection;
if (projection) {
point = projection.project(point);
point = projection.unproject(point);
}
return this.pointToProjected(point);
}
Expand All @@ -220,6 +220,10 @@ class Geo extends View {
return super.pointToData(point);
}

projectedToPoint(projected: number[], noRoam?: boolean, out?: number[]) {
return super.dataToPoint(projected, noRoam, out);
}

convertToPixel(ecModel: GlobalModel, finder: ParsedModelFinder, value: number[]): number[] {
const coordSys = getCoordSys(finder);
return coordSys === this ? coordSys.dataToPoint(value) : null;
Expand Down

0 comments on commit d9ba7c2

Please sign in to comment.