L7 icon indicating copy to clipboard operation
L7 copied to clipboard

线图层shape默认line,切换到arc,再切回来,图层消失

Open coderhyh opened this issue 7 months ago • 2 comments

问题描述

使用官方案例修改了下代码 官方案例

/* eslint-disable no-eval */
import { LineLayer, PointLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';

const scene = new Scene({
  id: 'map',
  map: new GaodeMap({
    pitch: 40,
    center: [40, 40.16797],
    style: 'dark',
    zoom: 2.5,
  }),
});
scene.addImage(
  'plane',
  'https://gw.alipayobjects.com/zos/bmw-prod/0ca1668e-38c2-4010-8568-b57cb33839b9.svg',
);
scene.on('loaded', () => {
  Promise.all([
    fetch(
      'https://gw.alipayobjects.com/os/bmw-prod/2960e1fc-b543-480f-a65e-d14c229dd777.json',
    ).then((d) => d.json()),
    fetch(
      'https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json',
    ).then((d) => d.text()),
    fetch(
      'https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json',
    ).then((d) => d.text()),
  ]).then(function onLoad([world, dot, flyline]) {
    // @ts-ignore
    const flydata = eval(flyline).map((item) => {
      // @ts-ignore
      const latlng1 = item.from.split(',').map((e) => {
        return e * 1;
      });
      // @ts-ignore
      const latlng2 = item.to.split(',').map((e) => {
        return e * 1;
      });
      return { coord: [latlng1, latlng2] };
    });

    const flyLine2 = new LineLayer()
      .source(flydata, {
        parser: {
          type: 'json',
          coordinates: 'coord',
        },
      })
      .color('#ff6b34')
      .shape('arc')
      .size(1)
      .style({
        lineType: 'dash',
        dashArray: [5, 5],
        opacity: 0.5,
      });
    scene.addLayer(flyLine2);
    setTimeout(() => {
      flyLine2.shape('line');
      scene.render();
      
      setTimeout(() => {
        flyLine2.shape('arc');
        scene.render();
      }, 2000);
    }, 2000);
  });
});

重现链接

No response

重现步骤

No response

预期行为

No response

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

coderhyh avatar May 29 '25 16:05 coderhyh

hi @coderhyh, welcome!

github-actions[bot] avatar May 29 '25 16:05 github-actions[bot]

Hi @coderhyh, Please star this repo if you find it useful! Thanks :star:! 你好~ @coderhyh 🌟 如果这个仓库对你有帮助,可以给我们点个star支持一下~你的支持对我们来说是最大的鼓励,感谢你的支持与点赞 🌟

github-actions[bot] avatar May 29 '25 16:05 github-actions[bot]