-
Notifications
You must be signed in to change notification settings - Fork 660
Feat arrow line #2792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lzxue
wants to merge
11
commits into
master
Choose a base branch
from
feat_arrow_line
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat arrow line #2792
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
29ee4cb
feat: 线支持显示箭头
lzxue 54fae5f
feat: 优化箭头显示
lzxue 914912f
fix: marker 交互事件
lzxue 5689434
Update packages/layers/src/core/interface.ts
lzxue 1d18130
Update packages/layers/src/core/triangulation.ts
lzxue 6969ec0
chore: 接口定义
lzxue 4752383
chore: ci 错误
lzxue 425d9c1
chore: 优化shader
lzxue 7fd1452
fix: lint error
lzxue c93c4d6
refactor: remove unnecessary eslint-disable comments
lzxue 101326e
chore: code format optimization
lzxue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import { LineLayer, Source } from '@antv/l7'; | ||
| import type { TestCase } from '../../types'; | ||
| import { CaseScene } from '../../utils'; | ||
|
|
||
| /** | ||
| * Arrow Line Demo | ||
| * | ||
| * 该示例演示如何在 L7 中为线图层添加箭头效果,常用于导航、路径方向标识。 | ||
| * | ||
| * 支持的箭头参数: | ||
| * - enable: 是否显示箭头 | ||
| * - spacing: 箭头间距(像素) | ||
| * - width: 箭头宽度(像素) | ||
| * - length: 箭头长度(像素) | ||
| * - strokeWidth: 箭头线条宽度(像素) | ||
| * - color: 箭头颜色(支持 CSS 色值) | ||
| * | ||
| * 箭头为 V 形轮廓,非实心三角,叠加在线本身之上。 | ||
| * 线和箭头可分别设置颜色,实现如“蓝色线+黄色箭头”效果。 | ||
| * | ||
| * 示例配置: | ||
| * arrow: { | ||
| * enable: true, | ||
| * spacing: 80, | ||
| * width: 30, | ||
| * length: 40, | ||
| * strokeWidth: 4, | ||
| * color: '#FFFF00', | ||
| * } | ||
| */ | ||
|
|
||
| export const arrowDebug: TestCase = async (options) => { | ||
| const scene = await CaseScene({ | ||
| ...options, | ||
| mapConfig: { | ||
| style: 'dark', | ||
| center: [120, 30], | ||
| zoom: 10, | ||
| }, | ||
| }); | ||
|
|
||
| console.log('=== Arrow Debug Demo Started ==='); | ||
|
|
||
| // 一条简单的水平线用于测试 | ||
| const simpleLineData = { | ||
| type: 'FeatureCollection', | ||
| features: [ | ||
| { | ||
| type: 'Feature', | ||
| properties: { name: 'test' }, | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [119.9, 30], | ||
| [120.1, 30], | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const arrowConfig = { | ||
| enable: true, | ||
| spacing: 15, // 间距 (像素) | ||
| width: 15, // 宽度 (像素) | ||
| length: 3, // 长度 (像素) | ||
| strokeWidth: 4, // 箭头线条宽度 (像素) | ||
| color: 'rgba(255, 94, 0, 1)', // 黄色箭头 | ||
| }; | ||
|
|
||
| console.log('Creating line layer with arrow config:', arrowConfig); | ||
|
|
||
| // 蓝色线,带黄色箭头 | ||
| const lineLayer = new LineLayer({ name: 'debug_arrow' }) | ||
| .source(new Source(simpleLineData)) | ||
| .shape('line') | ||
| .size(10) // 线宽 10px | ||
| .color('#0000FF') // 蓝色 | ||
| .style({ | ||
| arrow: arrowConfig, | ||
| }); | ||
|
|
||
| console.log('Line layer created, adding to scene...'); | ||
| scene.addLayer(lineLayer); | ||
| console.log('Line layer added to scene'); | ||
|
|
||
| // 添加一条不带箭头的对照线 - 青色 | ||
| const normalLine = new LineLayer({ name: 'normal_line' }) | ||
| .source( | ||
| new Source({ | ||
| type: 'FeatureCollection', | ||
| features: [ | ||
| { | ||
| type: 'Feature', | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [119.9, 30.05], | ||
| [120.1, 30.05], | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }), | ||
| ) | ||
| .shape('line') | ||
| .size(8) | ||
| .color('#00FFFF'); // 改为青色对照线,不带箭头 | ||
|
|
||
| scene.addLayer(normalLine); | ||
| console.log('Normal line (without arrows) added for comparison - cyan color'); | ||
|
|
||
| // 延迟检查图层配置 | ||
| setTimeout(() => { | ||
| const config = lineLayer.getLayerConfig(); | ||
| console.log('Layer config after add:', config); | ||
| console.log('Arrow config from layer:', (config as any).arrow); | ||
| }, 1000); | ||
|
|
||
| return scene; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| import { LineLayer, Source } from '@antv/l7'; | ||
| import type { TestCase } from '../../types'; | ||
| import { CaseScene } from '../../utils'; | ||
|
|
||
| export const arrow: TestCase = async (options) => { | ||
| const scene = await CaseScene({ | ||
| ...options, | ||
| mapConfig: { | ||
| style: 'light', | ||
| center: [120.15, 30.25], | ||
| zoom: 13, | ||
| }, | ||
| }); | ||
|
|
||
| // 模拟道路路径数据 | ||
| const roadData = { | ||
| type: 'FeatureCollection', | ||
| features: [ | ||
| { | ||
| type: 'Feature', | ||
| properties: { | ||
| name: '主干道', | ||
| }, | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [120.1, 30.2], | ||
| [120.12, 30.22], | ||
| [120.15, 30.24], | ||
| [120.18, 30.26], | ||
| [120.2, 30.28], | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| type: 'Feature', | ||
| properties: { | ||
| name: '支路', | ||
| }, | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [120.1, 30.28], | ||
| [120.12, 30.26], | ||
| [120.14, 30.24], | ||
| [120.16, 30.22], | ||
| ], | ||
| }, | ||
| }, | ||
| { | ||
| type: 'Feature', | ||
| properties: { | ||
| name: '环形路', | ||
| }, | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [120.18, 30.2], | ||
| [120.2, 30.21], | ||
| [120.21, 30.23], | ||
| [120.2, 30.25], | ||
| [120.18, 30.26], | ||
| [120.16, 30.25], | ||
| [120.15, 30.23], | ||
| [120.16, 30.21], | ||
| [120.18, 30.2], | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| const source = new Source(roadData); | ||
|
|
||
| // 创建带箭头的线图层 - 蓝色线条 | ||
| const lineLayer = new LineLayer({ name: 'arrow_line' }) | ||
| .source(source) | ||
| .shape('line') | ||
| .size(6) | ||
| .color('#1890ff') | ||
| .style({ | ||
| arrow: { | ||
| enable: true, | ||
| spacing: 30, // 间距 (像素) | ||
| width: 10, // 宽度 (像素) | ||
| length: 5, // 长度 (像素) | ||
| strokeWidth: 5, | ||
| color: 'rgba(255, 94, 0, 1)', // 黄色箭头 | ||
| }, | ||
| }); | ||
|
|
||
| scene.addLayer(lineLayer); | ||
|
|
||
| // 添加一个白色箭头的测试图层 | ||
| const whiteArrowLayer = new LineLayer({ name: 'white_arrow_line' }) | ||
| .source( | ||
| new Source({ | ||
| type: 'FeatureCollection', | ||
| features: [ | ||
| { | ||
| type: 'Feature', | ||
| geometry: { | ||
| type: 'LineString', | ||
| coordinates: [ | ||
| [120.1, 30.3], | ||
| [120.15, 30.3], | ||
| [120.2, 30.3], | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }), | ||
| ) | ||
| .shape('line') | ||
| .size(6) | ||
| .color('red') | ||
| .style({ | ||
| arrow: { | ||
| enable: true, | ||
| spacing: 30, // 间距 (像素) | ||
| width: 10, // 宽度 (像素) | ||
| length: 5, // 长度 (像素) | ||
| strokeWidth: 5, | ||
| }, | ||
| }); | ||
|
|
||
| scene.addLayer(whiteArrowLayer); | ||
|
|
||
| return scene; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的
arrow配置存在几个问题:count属性:配置中使用了count: 2,但arrow的接口定义(ILineLayerStyleOptions)中并没有count这个属性。这是一个未记录、未类型化的属性,请在接口中添加并提供文档。width和height单位:width和height的值(0.003和0.004)非常小,看起来像是地理坐标单位。然而,文档和实现都表明这些值应该是像素单位。这会导致箭头无法正确渲染。请将其修改为合理的像素值。rgba(255, 94, 0, 1)是橙色,而不是“黄色箭头”。