Skip to content

fix(maps): 修复 tdtmap/tmap 的 once() throw stub,清理冗余 override - #2879

Merged
lzxue merged 1 commit into
masterfrom
fix/maps-once-stub-and-redundant-overrides
Jul 19, 2026
Merged

fix(maps): 修复 tdtmap/tmap 的 once() throw stub,清理冗余 override#2879
lzxue merged 1 commit into
masterfrom
fix/maps-once-stub-and-redundant-overrides

Conversation

@lzxue

@lzxue lzxue commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

背景

基座改造 (#2875 #2877 #2878) 过程中发现一个潜在的运行时 bug + 一批迁移后冗余的 override。本 PR 收敛处理。

Bugfix: once() throw stub

tdtmap/map.tstmap/map.tsonce() 方法是 throw new Error('Method not implemented.') 的空 stub,其中 tmap 甚至把签名降级成 once(): void

// tdtmap/map.ts (原 L303)
public once(type: string, handler: (...args: any[]) => void): void {
  throw new Error('Method not implemented.');
}
// tmap/map.ts (原 L270, 签名甚至丢了参数)
public once(): void {
  throw new Error('Method not implemented.');
}

影响面

scene/src/index.ts:362this.mapService.once(type, handle),使用 tdtmap / tmap 作为地图底图时该调用直接抛异常

修复

二者基类均已提供可用实现:

  • tdtmap extends BaseMapBaseMap.once = this.eventEmitter.once(name, handler)
  • tmap extends BaseMapServiceBaseMapService.once = this.eventEmitter.once(name, ...args)

删除 stub 即可让 once 正常继承基类实现工作。tmap 的 stub 还误把可用基类实现覆盖坏了,删除后恢复正确行为。

Cleanup: 冗余 override (逐字节与基类一致,行为不变)

迁移到 BaseMap / MapboxBaseMap 后, 以下 override 与基类实现完全相同, 纯死代码:

文件 方法
gmap/map.ts onCameraChanged, setBgColor
tdtmap/map.ts onCameraChanged
amap-next/map.ts getMapContainer (return this.mapContainer;)

均为机械删除, 不改运行时行为

不在本 PR 范围

验证

  • tsc --noEmit -p packages/maps 仅 4 个本地 @types 全局错误 (baseline)
  • 受影响文件 (tdtmap/tmap/gmap/amap-next) 无新增 ts 错误
  • prettier format-check 全绿
  • 净变更: 4 files changed, 23 deletions(-)

## bugfix
- `tdtmap/map.ts` 与 `tmap/map.ts` 的 `once()` 是 `throw new Error('Method not implemented.')`
  的空 stub (tmap 甚至把签名降级成 `once(): void`)。
  - 调用方 `scene/src/index.ts:362 this.mapService.once(type, handle)` 在使用 tdtmap/tmap 时
    会直接抛异常。
  - 二者基类 (tdtmap extends BaseMap / tmap extends BaseMapService) 均已有可用的
    `eventEmitter.once` 实现,删除该 stub 即可让 once 正常工作。
  - tmap 的 stub 还错误地覆盖了基类的可用实现,删除后恢复正确行为。

## cleanup: 冗余 override (与基类实现逐字节一致,行为不变,纯死代码)
- `gmap/map.ts`: `onCameraChanged`、`setBgColor` (BaseMap 已实现相同体)
- `tdtmap/map.ts`: `onCameraChanged`
- `amap-next/map.ts`: `getMapContainer` (return this.mapContainer,与 BaseMap 一致)

## 验证
- tsc --noEmit -p packages/maps 仅 4 个本地 @types 全局错误 (baseline)
- prettier format-check 全绿
- 受影响文件无新增 ts 错误
@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 82349cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request cleans up the codebase by removing several unused, redundant, or unimplemented methods across different map service classes, including AMapService, GMapService, TdtMapService, and TMapService. Specifically, methods such as getMapContainer, onCameraChanged, setBgColor, and once have been removed. There are no review comments, and we have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@lzxue
lzxue merged commit fd925f8 into master Jul 19, 2026
8 checks passed
@lzxue
lzxue deleted the fix/maps-once-stub-and-redundant-overrides branch July 19, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant