L7 icon indicating copy to clipboard operation
L7 copied to clipboard

现在应该如何使用LineLayer绘制若干个箭头?

Open S-TE11A opened this issue 2 years ago • 8 comments

问题描述

image 希望使用LineLayer绘制出上述效果,尝试过以下方案:

  1. 使用flowline,flowline是双向箭头 无法实现单向
  2. 之前LineLayer.style 有arrow选项, 但是现在似乎已经废弃 请问应该如何实现上述效果?

重现链接

No response

重现步骤

No response

预期行为

No response

平台

No response

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

S-TE11A avatar Dec 12 '23 15:12 S-TE11A

hi @SyraTi, welcome!

github-actions[bot] avatar Dec 12 '23 15:12 github-actions[bot]

Hi @SyraTi, Please star this repo if you find it useful! Thanks :star:! 你好 @SyraTi。如果该仓库对你有用,可以 star 一下,感谢你的 :star:!

github-actions[bot] avatar Dec 12 '23 15:12 github-actions[bot]

flowline 单双方向都支持

lzxue avatar Dec 13 '23 02:12 lzxue

import { Scene, LineLayer } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';

const scene = new Scene({
  id: 'map',
  map: new GaodeMap({
    pitch: 60,
    style: 'dark',
    center: [ 104.34278, 41.12554 ],
    zoom: 2.94888,
    rotation: 42.3999
  })
});
scene.on('loaded', () => {
  fetch('https://gw.alipayobjects.com/os/bmw-prod/e495c407-953b-44cc-8f77-87b9cf257578.json')
    .then(res => res.json())
    .then(data => {
      const layer = new LineLayer({})
        .source(data, {
          parser: {
            type: 'json',
            x: 'from_lon',
            y: 'from_lat',
            x1: 'to_lon',
            y1: 'to_lat'
          }
        })
        .size(5)
        .shape('flowline')
        .color('#FF7C6A')
        .style({
          opacity: 0.8,
          symbol:{
                target:'classic',
                source:'none',
              },
        });
      scene.addLayer(layer);
    });
});

测试了一下,效果再优化一下

lzxue avatar Dec 13 '23 02:12 lzxue

import { Scene, LineLayer } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';

const scene = new Scene({
  id: 'map',
  map: new GaodeMap({
    pitch: 60,
    style: 'dark',
    center: [ 104.34278, 41.12554 ],
    zoom: 2.94888,
    rotation: 42.3999
  })
});
scene.on('loaded', () => {
  fetch('https://gw.alipayobjects.com/os/bmw-prod/e495c407-953b-44cc-8f77-87b9cf257578.json')
    .then(res => res.json())
    .then(data => {
      const layer = new LineLayer({})
        .source(data, {
          parser: {
            type: 'json',
            x: 'from_lon',
            y: 'from_lat',
            x1: 'to_lon',
            y1: 'to_lat'
          }
        })
        .size(5)
        .shape('flowline')
        .color('#FF7C6A')
        .style({
          opacity: 0.8,
          symbol:{
                target:'classic',
                source:'none',
              },
        });
      scene.addLayer(layer);
    });
});

测试了一下,效果再优化一下

好的,感谢,另外想问一下关于symbol的文档,似乎没有在官网看到? 是flowline的文档还没有完善吗?

S-TE11A avatar Dec 13 '23 10:12 S-TE11A

另外想请问下symbol从哪个版本开始支持?

S-TE11A avatar Dec 13 '23 12:12 S-TE11A

image 这些箭头的效果似乎也有些问题, 有配置可以修正吗 @lzxue

S-TE11A avatar Dec 13 '23 13:12 S-TE11A

image 这些箭头的效果似乎也有些问题, 有配置可以修正吗 @lzxue

最新版本已经修复了,你看一下

lzxue avatar Dec 22 '23 02:12 lzxue