Skip to content

fix: LineLayer shape 切换后重建模型#2841

Open
lzxue wants to merge 1 commit intomasterfrom
fix/line-layer-shape-rebuild
Open

fix: LineLayer shape 切换后重建模型#2841
lzxue wants to merge 1 commit intomasterfrom
fix/line-layer-shape-rebuild

Conversation

@lzxue
Copy link
Copy Markdown
Contributor

@lzxue lzxue commented Mar 27, 2026

问题

修复 Issue #2714: 线图层shape默认line,切换到arc,再切回来,图层消失

原因

当调用 layer.shape() 方法改变 shape 时,没有触发模型重建。

解决方案

在 LineLayer 中重写 rebuildModels 方法,类似于 PointLayer 的做法,在 shape 改变后调用 buildModels 重建模型。

测试

const layer = new LineLayer()
  .source(data)
  .shape(line)
  .style({ stroke: #f00 })

// 切换到 arc 
layer.shape("arc")

// 再切回 line - 之前会消失,现在应该正常显示
layer.shape("line")

修复 Issue #2714: 线图层shape默认line,切换到arc,再切回来,图层消失

问题原因:当调用 layer.shape() 方法改变 shape 时,没有触发模型重建。
解决方案:重写 rebuildModels 方法,在 shape 改变后调用 buildModels 重建模型。
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 27, 2026

⚠️ No Changeset found

Latest commit: 9284d27

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

Copy link
Copy Markdown
Contributor

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

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 adds a rebuildModels method to LineLayer. However, as noted in the review, this implementation is redundant because the base class BaseLayer already provides the same functionality, and the method should be removed to simplify the codebase.

Comment on lines +37 to +39
public async rebuildModels() {
await this.buildModels();
}
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

rebuildModels 方法已经在基类 BaseLayer 中以完全相同的逻辑实现。由于 LineLayer 继承自 BaseLayer,这个显式的覆盖是多余的,可以移除以简化代码。继承的方法会调用 this.buildModels(),并正确地解析为 LineLayer 中的实现。

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