Skip to content

refactor(maps): migrate bmap & tmap to BaseMap, delete BaseMapService - #2878

Merged
lzxue merged 1 commit into
masterfrom
refactor/basemap-bmap-tmap-migration
Jul 19, 2026
Merged

refactor(maps): migrate bmap & tmap to BaseMap, delete BaseMapService#2878
lzxue merged 1 commit into
masterfrom
refactor/basemap-bmap-tmap-migration

Conversation

@lzxue

@lzxue lzxue commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

背景

承接 #2875 (gmap/tdtmap 迁移) 与 #2877 (mapbox 四兄弟迁移到 MapboxBaseMap) 的基座改造收尾。BaseMapService 此前作为 BaseMap 的过渡兼容层被 @deprecated 标记, 仅剩 bmap / tmap 两个消费者。本 PR 将二者迁移完成后, 一次性删除 466 行历史死代码。

改动

bmap/map.ts

  • extends BaseMapService<BMapGL.Map>extends BaseMap<BMapGL.Map>
  • 移除 // TODO: 基于抽象类 BaseMap 实现 注释
  • $mapContainermapContainer (与基类统一命名, 3 处)
  • 补全 BaseMap 声明为 abstract 的 3 个小方法:
    • getMapStyle()'' (bmap 无 mapbox getStyle API, 用 setMapStyleV2 + currentStyle 跟踪)
    • setMaxZoom(max) / setMinZoom(min)this.map.setMaxZoom?.(max) 可选调用兼容

tmap/map.ts

  • extends BaseMapService<TMap.Map>extends BaseMap<TMap.Map>
  • 移除 TODO 注释; $mapContainermapContainer (2 处)
  • 补全 4 个 abstract 方法:
    • getMapStyle()''
    • getMapStyleConfig()MapTheme (新增 import { MapTheme } from '../utils/theme')
    • setMaxZoom / setMinZoom(this.map as any).setMaxZoom?.(max) (TMap 无可靠 setter, no-op 安全)

删除

  • packages/maps/src/utils/BaseMapService.ts (466 行 @deprecated)
  • utils/index.ts 移除 BaseMapService 导出 (保留 BaseMapWrapper, 仍被各 wrapper 使用)

语义说明

  • 迁移为机械替换 + 补 stub, 不改运行时行为。bmap/tmap 原本就 self-implement 几乎全部方法, 仅继承自 BaseMapService 的几个 stub 现显式落到子类, 行为一致。
  • setMaxZoom/setMinZoom 在 BaseMapService 里是 @deprecated 空实现 (throw 'Method not implemented'), bmap 现实现为可选调用 map.setMaxZoom?.(max), 行为更合理且与 gmap/tdtmap 一致, 属微小增强而非破坏性变更。

验证

  • tsc --noEmit -p packages/maps 仅 4 个本地 @types 全局错误 (baseline: tmap-types / amap-js-api / bmapgl / google.maps)
  • packages/maps/src/{bmap,tmap,utils} 无新增 ts 错误
  • prettier format-check 全绿 (organize-imports 未破坏任何在用 import)

收益

迁移后 basemap 类继承结构最终收敛为:

彻底移除 BaseMapService 历史包袱, 后续地图适配器只需面向 BaseMap 单一抽象。

bmap/map.ts 和 tmap/map.ts 迁移:
- extends BaseMapService<X> -> extends BaseMap<X>
- $mapContainer -> mapContainer (基类统一命名)
- 补全 BaseMap 声明为 abstract 的小方法:
  - getMapStyle() -> ''  (bmap/tmap 无 mapbox getStyle API)
  - getMapStyleConfig() -> MapTheme  (tmap 新增, bmap 已有 styleConfig)
  - setMaxZoom/setMinZoom -> 兼容可选调用 map.setMaxZoom?.(max)

删除 BaseMapService.ts (466 行 @deprecated 死代码):
- 仅剩 bmap/tmap 两个消费者, 迁移完即删除
- utils/index.ts 同步移除导出, 保留 BaseMapWrapper

验证:
- tsc --noEmit -p packages/maps 仅 4 个本地 @types 全局错误 (baseline)
- prettier format-check 全绿
@changeset-bot

changeset-bot Bot commented Jul 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b3cacd0

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 refactors the map services by removing the deprecated BaseMapService abstract class and migrating BMapService and TMapService to extend the new BaseMap class. It also implements missing methods such as setMaxZoom, setMinZoom, and getMapStyle in both services. The feedback suggests returning this.currentStyle instead of an empty string in BMapService.getMapStyle(), and using setOptions to correctly apply zoom limits in TMapService since Tencent Map does not support direct setMinZoom/setMaxZoom methods.

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.

Comment thread packages/maps/src/bmap/map.ts
Comment thread packages/maps/src/tmap/map.ts
@lzxue
lzxue merged commit 3f81df9 into master Jul 19, 2026
8 checks passed
@lzxue
lzxue deleted the refactor/basemap-bmap-tmap-migration branch July 19, 2026 13:59
lzxue added a commit that referenced this pull request Jul 23, 2026
#2878 迁移 bmap/tmap 到 BaseMap 后 SDK 类型缺
on/off/getMinZoom/getMaxZoom/getContainer/panBy 等成员声明,
father declaration 生成失败, 阻塞 fixed group 发布。

新增 ambient map-sdk-augmentation.d.ts 用 namespace 接口合并
补齐; bmap 补 version 声明; handleCameraChanged 改可选调用
cameraChangedCallback?.。

全量 pnpm build 通过, 无运行时行为变更。
详 .changeset/fix-maps-bmap-tmap-types.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant