refactor(maps): migrate bmap & tmap to BaseMap, delete BaseMapService - #2878
Conversation
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 全绿
|
There was a problem hiding this comment.
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.
#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
背景
承接 #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 实现注释$mapContainer→mapContainer(与基类统一命名, 3 处)BaseMap声明为 abstract 的 3 个小方法:getMapStyle()→''(bmap 无 mapboxgetStyleAPI, 用setMapStyleV2+currentStyle跟踪)setMaxZoom(max)/setMinZoom(min)→this.map.setMaxZoom?.(max)可选调用兼容tmap/map.ts
extends BaseMapService<TMap.Map>→extends BaseMap<TMap.Map>$mapContainer→mapContainer(2 处)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 使用)语义说明
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 错误收益
迁移后 basemap 类继承结构最终收敛为:
BaseMap(抽象基类, ~240 行)MapboxBaseMap extends BaseMap(mapbox 中间基类, refactor(maps): migrate mapbox family (map/mapbox/maplibre/earth) to MapboxBaseMap #2877)extends BaseMap/extends MapboxBaseMap彻底移除
BaseMapService历史包袱, 后续地图适配器只需面向BaseMap单一抽象。