Skip to content

chore: map - #2815

Closed
lzxue wants to merge 56 commits into
masterfrom
fix_heatmap
Closed

chore: map#2815
lzxue wants to merge 56 commits into
masterfrom
fix_heatmap

Conversation

@lzxue

@lzxue lzxue commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

[English Template / 英文模板]

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 工作流程
  • 版本更新
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

📝 更新日志

语言 更新描述
🇺🇸 英文
🇨🇳 中文

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

lzxue and others added 30 commits January 23, 2026 17:18
- Auto create PR when .skills directory changes
- File validation (type, size, content check)
- Only run on official antvis/L7 repository
- Support manual trigger with force option
1. 修复蜂窝热力图 (hexagon):
   - 调整六边形方向为 pointy-top,与 d3-hexbin 一致
   - 翻转 y 坐标方向以匹配屏幕坐标系

2. 修复网格热力图 (grid):
   - 改用屏幕像素坐标划分网格,与 hexagon 一致
   - 修正 xOffset/yOffset 计算:正方形顶点范围是 [-√2/2, √2/2]

3. 修复 count 聚合方法:
   - 在 statMap 中添加 count 方法

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要优化:
- TileLayerService: 使用 Map 存储瓦片实例,查找复杂度从 O(n) 降为 O(1)
- TileLayerService: 实现分帧销毁机制,避免大量瓦片销毁阻塞渲染
- TileLayerService: 添加渲染列表缓存和脏标记,减少每帧重建
- BaseLayer: 合并多个 filter 操作,减少中间数组创建
- BaseLayer: 优化视图状态比较,使用数值比较替代字符串比较
- TilesetManager: 缓存 tiles getter,避免每次访问都排序
- TilesetManager: 使用 Set 存储当前瓦片 key,加速查找
- TilesetManager: 合并 updateTileVisible 遍历,减少迭代次数
- SourceTile: 缓存 bounds 和 bboxPolygon,避免重复计算
- TilePickService: 优化遍历,跳过未加载的瓦片

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要优化:
- math.ts: 表达式预编译为函数,避免循环中 JSON 序列化/反序列化
  - 对于 256x256 瓦片,从 65536 次序列化操作优化为 1 次编译
  - 预分配 Float32Array 结果数组,避免动态扩容
- operationSchema.ts: 使用快速选择算法计算百分位
  - 复杂度从 O(n log n) 降到 O(n)
  - 预分配 Uint8Array 数组存储 RGB 数据
- getRasterData.ts: 多波段数据并行请求
  - 使用 Promise.all 并行请求,减少网络等待时间

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
主要修复:
1. 修复 UBO std140 布局问题 - vec3 只占 3 floats,之前的布局导致 u_RelativeOrigin 位置错误
2. 修复 extrude/water/ocean 图层在相对坐标模式下 UV 计算错误
3. 修复 Pipeline 缓存 key 生成不完整导致的状态不一致问题

性能优化:
1. 添加颜色解析缓存 (rgb2arr),避免重复解析相同颜色
2. 优化数据映射插件的过滤流程,减少遍历次数
3. 添加质心计算缓存

其他修复:
1. 移除地图适配器中的硬编码 API Keys
2. 修复 Scene.emit 调用错误

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- fix: 修复 citybuliding 目录名拼写错误 (citybuliding -> citybuilding)
- refactor: 用自定义实现替代 lodash 依赖,优化包大小
- refactor: 将 SimpleMapCoord 移到 maps 包本地 utils
- fix: 添加 getDefault 方法返回类型
- fix: 修复 merge 函数的类型参数
- fix: 添加 initCfg 方法 option 参数的条件检查
- chore: 更新 build 脚本,添加 clean-dist 步骤

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/source/src/utils/csv.ts 实现 csvParse 函数
- 支持 CSV 基础解析、引号处理、转义引号、各种换行符
- 移除 d3-dsv 和 @types/d3-dsv 依赖
- 添加完整的单元测试覆盖边界情况

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 在 lodash-adapter.ts 中添加 extent 函数实现
- 移除 d3-array 和 @types/d3-array 依赖
- 更新 FeatureScalePlugin 使用 lodashUtil.extent
- 添加 lodash-adapter 单元测试

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/utils/src/color-parser.ts 实现颜色解析
- 支持 hex、rgb/rgba、hsl/hsla 和 CSS 颜色名称
- 更新 color.ts 使用自定义 parseColor 函数
- 移除 utils 和 layers 包中的 d3-color 依赖

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 在 color-parser.ts 中添加 interpolateRgbBasis 函数
- 实现分段线性颜色插值功能
- 更新 FeatureScalePlugin 使用自定义 interpolateRgbBasis
- 移除 layers 包中的 d3-interpolate 依赖

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/source/src/utils/hexbin.ts 实现六边形分箱算法
- 使用 odd-q offset 坐标系统与 d3-hexbin 兼容
- 更新 hexagon.ts 使用自定义 hexbin 函数
- 移除 d3-hexbin 和 @types/d3-hexbin 依赖

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 将 odd-q 偏移(奇数列偏移)改为 odd-r 偏移(奇数行偏移)
- 完全复制 d3-hexbin 的分箱算法逻辑
- 修复中心坐标计算方式:
  - x = (pi + (pj & 1) / 2) * dx
  - y = pj * dy
- 修复访问器类型签名以支持 3 个参数

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 新增 packages/layers/src/utils/scale.ts 实现 10 种比例尺
- scaleLinear, scalePow, scaleLog: 连续比例尺
- scaleSequential, scaleDiverging: 连续颜色比例尺
- scaleQuantile, scaleQuantize, scaleThreshold: 离散比例尺
- scaleOrdinal: 枚举比例尺
- scaleTime: 时间比例尺
- 更新 FeatureScalePlugin 使用自定义比例尺
- 移除 d3-scale 和 @types/d3-scale 依赖

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 添加 sanitizeDomain 函数处理 domain 中的 undefined、null、NaN 值
- 修复当 extent 返回 [undefined, undefined] 时导致 NaN 计算的问题
- 处理 domain 只有一个值或为空的情况
- 处理 domain[0] === domain[1] 时除以零的问题
- 所有连续比例尺现在都对无效输入有容错处理

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 移除 lodash 依赖(已有自定义 lodash-adapter 实现)
- 移除 layers 包中未使用的 extrude-polyline、polyline-miter-util、gl-vec2

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 使用现代浏览器原生支持的 ResizeObserver API
- 移除 element-resize-detector 和 @types/element-resize-detector 依赖
- 减少第三方依赖,提升稳定性

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lzxue and others added 9 commits February 22, 2026 16:05
- 解决 heatmap.ts 中 this.layer.shapeOption 类型错误

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 移除 utils 包中未使用的 web-worker-helper
- 移除 core 包中未使用的 ajv(相关代码已被注释)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 使用 pointerdown/pointermove/pointerup 替换 Hammer.Pan 实现拖拽
- 使用原生 click/dblclick 事件替换 Hammer.Tap
- 使用计时器模拟长按(press)事件
- 移除 hammerjs 和 @types/hammerjs 依赖

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
主要改进:
- 统一使用 Pointer Events API 处理鼠标和触摸事件,移除冗余监听
- 提取坐标转换逻辑为公共方法,减少重复代码
- 优化单击/双击检测逻辑,区分 click 和 dblclick 事件
- 修复 mousedown 监听器内存泄漏(capture 参数不匹配)
- 添加容器边界缓存,优化性能
- 新增 Press 事件类型,语义更清晰

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
新增 refactor 测试分类,包含以下验证场景:
- interactionTest: 交互测试(拖拽、单击、双击、长按、hover、contextmenu)
- resizeObserverTest: ResizeObserver测试(容器大小变化、canvas自适应)
- displayTest: 显示测试(点、线、多边形、热力图各图层渲染)
- animationTest: 动画测试(波纹动画、流动线动画、数据更新动画)
- eventsTest: 事件系统测试(所有InteractionEvent类型统计)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 使用 querySelector 从容器中获取 canvas 元素

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. 移除 onClick/onDoubleClick 中的 stopPropagation,允许事件冒泡到底层地图
2. 通过 Hover 事件发送 mousedown/mouseup/click/dblclick,保持向后兼容
3. 添加 vite optimizeDeps.exclude 配置,避免 esbuild 预构建本地包
4. 修复 l7-draw demo 文件中的事件监听和 API 使用问题

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. 添加 @antv/l7-draw 开发依赖用于测试
2. 升级 vite-plugin-string 到 1.2.3
3. 添加 .playwright-mcp 到 .gitignore
4. 代码格式化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
独立添加的 Marker(通过 scene.addMarker)之前没有注册相机变化事件,
导致地图缩放/平移时 marker 位置不更新。现已在 MarkerService 中添加
camerachange/viewchange 事件监听来同步更新所有 marker 位置。

同时修复了 addMarkerLayers 方法中错误清空 unAddMarkers 的 bug。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Feb 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7d60f8b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@antv/l7-component Major
@antv/l7-renderer Major
@antv/l7-layers Major
@antv/l7-source Major
@antv/l7-scene Major
@antv/l7-utils Major
@antv/l7-core Major
@antv/l7-maps Major
@antv/l7 Major
@antv/l7-test-utils Major
@antv/l7-map Major
@antv/l7-three Major

Not sure what this means? Click here to learn what changesets are.

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

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @lzxue, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求主要在 examples/demos 目录下引入了一组新的“重构”测试用例。这些新的演示旨在验证潜在的依赖替换和代码重构后的各项功能正确性。具体而言,它们涵盖了动画效果、图层显示、事件处理(包括交互事件和场景/图层事件)以及 L7 Draw 库的几何图形绘制操作。此外,.gitignore 文件也已更新,以排除新的开发相关目录。

Highlights

  • 新增 .gitignore 忽略项: 更新了 .gitignore 文件,以排除新的开发相关目录,如 .agents/.github/skills/.playwright-mcp
  • 集成“重构”测试用例: 在 examples/demos/index.ts 中集成了新的 RefactorTestCases,将其添加到演示案例列表中,便于集中管理和测试重构后的功能。
  • 新增多项重构验证演示: 在 examples/demos/refactor/ 目录下新增了多个演示文件,用于验证动画、图层显示、事件系统、交互以及 L7 Draw 绘制等核心功能的正确性。
Changelog
  • .gitignore
    • 添加了新的忽略条目,用于排除 .agents/.github/skills/.playwright-mcp 目录。
  • examples/demos/index.ts
    • 导入了 RefactorTestCases 并将其添加到 TestCases 映射中,键名为 'refactor'。
  • examples/demos/refactor/animation.ts
    • 新增了一个图层动画测试用例,包括波纹点图层、流动线图层和动态数据更新,并提供了交互式控制。
  • examples/demos/refactor/display.ts
    • 新增了一个显示测试用例,用于验证各种图层类型(点图层、线图层、多边形图层、热力图层)的渲染功能,并提供了切换控制。
  • examples/demos/refactor/draw-circle.ts
    • 新增了一个使用 @antv/l7-draw 绘制圆的测试用例,包括半径显示和 GeoJSON 导出功能。
  • examples/demos/refactor/draw-line.ts
    • 新增了一个使用 @antv/l7-draw 绘制线的测试用例,包括距离显示和 GeoJSON 导出功能。
  • examples/demos/refactor/draw-point.ts
    • 新增了一个使用 @antv/l7-draw 绘制点的测试用例,支持自定义样式和 GeoJSON 导出。
  • examples/demos/refactor/draw-polygon.ts
    • 新增了一个使用 @antv/l7-draw 绘制多边形的测试用例,包括面积显示和 GeoJSON 导出功能。
  • examples/demos/refactor/draw-rect.ts
    • 新增了一个使用 @antv/l7-draw 绘制矩形的测试用例,包括面积显示和 GeoJSON 导出功能。
  • examples/demos/refactor/events.ts
    • 新增了一个事件系统测试用例,验证了交互事件(hover, click, dblclick, drag, press)以及场景和图层事件,并提供了实时日志面板。
  • examples/demos/refactor/index.ts
    • 添加了一个索引文件,用于导出所有新的重构测试用例。
  • examples/demos/refactor/interaction.ts
    • 新增了一个交互测试用例,专门验证拖拽、单击、双击、长按、悬停和右键菜单等事件在图层和场景上的功能。
  • examples/demos/refactor/resize.ts
    • 新增了一个 ResizeObserver 功能测试用例,验证了容器和窗口大小变化时画布的自动调整,并提供了交互式控制。
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/sync-skills.yml
Activity
  • 此拉取请求目前没有记录到具体的评论或审查活动。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@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

The pull request introduces a comprehensive set of refactor validation tests to ensure the replacement of hammerjs and element-resize-detector with native Pointer Events and ResizeObserver APIs works correctly. The tests cover animations, layer display, event systems, and drawing tools. I have identified several logic issues where event listeners are redundant because they are attached after the scene has already loaded, as well as potential memory leaks from uncleaned intervals and missing error handling in network requests.

);
};

let dataUpdateInterval: ReturnType<typeof setInterval> | null = setInterval(updateData, 500);

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.

medium

The setInterval created here is not cleaned up when the demo is destroyed or the user navigates away. This can lead to memory leaks and unnecessary background processing. It is recommended to clear the interval when the scene is removed.

Suggested change
let dataUpdateInterval: ReturnType<typeof setInterval> | null = setInterval(updateData, 500);
let dataUpdateInterval: ReturnType<typeof setInterval> | null = setInterval(updateData, 500);
scene.on('remove', () => dataUpdateInterval && clearInterval(dataUpdateInterval));

}
};

scene.on('loaded', () => log('场景加载完成'));

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.

medium

This loaded event listener is redundant. The CaseScene utility resolves only after the scene has already loaded, so this listener will never be triggered. You can call the log function directly.

Suggested change
scene.on('loaded', () => log('场景加载完成'));
log('场景加载完成');

Comment on lines +180 to +182
const heatmapData = await fetch(
'https://gw.alipayobjects.com/os/antfincdn/8Ps2h%24qgmk/traffic_110000.csv',
).then((res) => res.text());

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.

medium

The fetch request lacks error handling. If the network request fails or the resource is unavailable, the demo will fail to load or hang. Adding a .catch() block ensures the demo can handle such failures gracefully.

Suggested change
const heatmapData = await fetch(
'https://gw.alipayobjects.com/os/antfincdn/8Ps2h%24qgmk/traffic_110000.csv',
).then((res) => res.text());
const heatmapData = await fetch(
'https://gw.alipayobjects.com/os/antfincdn/8Ps2h%24qgmk/traffic_110000.csv',
).then((res) => res.text()).catch(() => '');

@@ -0,0 +1,150 @@
/**
* 多边形绘制测试 - 使用 @antv/l7-draw 绑定绑定绘制多边形

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.

medium

Typo: '绑定绑定' (bind bind) is repeated in the description.

Suggested change
* 多边形绘制测试 - 使用 @antv/l7-draw 绑定绑定绘制多边形
* 多边形绘制测试 - 使用 @antv/l7-draw 绑定绘制多边形

Comment on lines +164 to +166
scene.on('loaded', () => {
log('SCENE', 'loaded', '#0ff');
});

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.

medium

This loaded event listener is redundant because the CaseScene utility resolves after the scene is already loaded. The code inside this block will not execute.

  log('SCENE', 'loaded', '#0ff');

Comment on lines +59 to +61
scene.on('loaded', () => {
log('Scene loaded', '#0ff');
});

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.

medium

The loaded event has already fired by the time CaseScene resolves. This listener is redundant and will not be called.

  log('Scene loaded', '#0ff');

scene.addLayer(pointLayer);

// 定期更新状态
setInterval(updateStatus, 1000);

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.

medium

The setInterval used to update the status panel is never cleared, which will cause a memory leak when switching between demos. It should be cleared when the scene is removed.

Suggested change
setInterval(updateStatus, 1000);
const statusInterval = setInterval(updateStatus, 1000);
scene.on('remove', () => clearInterval(statusInterval));

lzxue and others added 16 commits February 23, 2026 13:33
## 高优先级修复
- fix: 修复 Popper destroy 时未从 conflictPopperList 移除实例的内存泄漏
- fix: 删除 Marker 中未实现的遗留方法 addDragHandler 和 onUp
- perf: 为 Popup 高频事件添加 RAF 节流,提升性能

## 中优先级修复
- perf: 优化 sideEffects 配置,精确声明副作用文件以提升 tree-shaking
- refactor: 新增 EventManager 工具类统一管理事件绑定/解绑
- chore: 删除源码中的构建产物 index.css,改用 less 源文件

## 低优先级修复
- test: 恢复 marker.spec.tsx 中被注释的测试用例
- test: 新增 eventManager.spec.ts 测试文件
- test: 新增 popper.spec.ts 测试文件验证内存泄漏修复

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
修改 ILayerPopupOption 接口,trigger 参数从必填改为可选。
默认值 'hover' 在 getDefault 方法中已定义。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
当用户未指定 trigger 时,getDefault 方法中 isHoverTrigger 判断错误。
现在先获取最终 trigger 值再判断是否为 hover 模式。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
添加明确的返回类型声明,并在 trigger 为 undefined 时使用默认值 'hover'。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Jest 配置添加 .less 文件支持
- ResizeObserver mock 添加 disconnect 方法
- popup 测试添加 fake timers 处理 RAF
- marker 测试添加 overflowHide: false 避免位置问题
- imageLayer/raster-tile 测试添加 afterEach 清理 scene
- citybuilding 测试跳过(gl 原生模块内存问题)
- source 测试更新 grid 聚合期望值

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 添加 yarn test、jest 等测试相关权限配置
- 更新集成测试快照图片
- 新增多个测试场景的快照文件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
配置 style-loader 替代 mini-css-extract-plugin,使 umd 产物的 css
直接打包进 l7.js,用户无需单独引入 css 文件。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 将 maxError 从 0 改为 100,允许 macOS 和 Linux CI 环境之间的渲染差异
- 添加 @rollup/rollup-darwin-arm64 依赖以支持本地测试运行
@lzxue lzxue closed this Feb 25, 2026
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