fix(maps): 修复 tdtmap/tmap 的 once() throw stub,清理冗余 override - #2879
Conversation
## 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 错误
|
There was a problem hiding this comment.
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.
背景
基座改造 (#2875 #2877 #2878) 过程中发现一个潜在的运行时 bug + 一批迁移后冗余的 override。本 PR 收敛处理。
Bugfix:
once()throw stubtdtmap/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 作为地图底图时该调用直接抛异常。修复
二者基类均已提供可用实现:
extends BaseMap→BaseMap.once = this.eventEmitter.once(name, handler)extends BaseMapService→BaseMapService.once = this.eventEmitter.once(name, ...args)删除 stub 即可让 once 正常继承基类实现工作。tmap 的 stub 还误把可用基类实现覆盖坏了,删除后恢复正确行为。
Cleanup: 冗余 override (逐字节与基类一致,行为不变)
迁移到
BaseMap/MapboxBaseMap后, 以下 override 与基类实现完全相同, 纯死代码:gmap/map.tsonCameraChanged,setBgColortdtmap/map.tsonCameraChangedamap-next/map.tsgetMapContainer(return this.mapContainer;)均为机械删除, 不改运行时行为。
不在本 PR 范围
bmap/map.ts的onCameraChanged/once同样冗余, 但 bmap 正在 refactor(maps): migrate bmap & tmap to BaseMap, delete BaseMapService #2878 中迁移 base class, 为避免双 PR 同改一文件留待 refactor(maps): migrate bmap & tmap to BaseMap, delete BaseMapService #2878 合并后清理。creatMapContainer在 mapbox 家族 (map/mapbox/maplibre/tdtmap) 重复了getElementById解析逻辑, 可后续 DRY 到super.creatMapContainer调用, 但属语义重构, 单独立项。验证
tsc --noEmit -p packages/maps仅 4 个本地@types全局错误 (baseline)