antvis / L7Draw

L7 绘制控件

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DrawLine完成折线绘制后报错

kuranwang opened this issue · comments

您好,最近在我自己的项目中使用DrawLine在地图上绘制折线,在点击最后一个点来完成绘制时会有(regl) invalid buffer data以及(uncatch in Promise)nvalid buffer data 的报错,一直没能解决,前来请教。我在codesandbox里运行如下代码:

import { AMapScene, LineLayer } from '@antv/l7-react';
import * as React from 'react';
import { Scene } from '@antv/l7';
import { DrawCircle,DrawLine } from '@antv/l7-draw';
import ReactDOM from 'react-dom';
import { Button } from 'antd';
import { GaodeMap } from "@antv/l7-maps";

const scene = new Scene({
  id: "map",
  map: new GaodeMap({
    pitch: 0,
    style: "light",
    center: [113.775374, 28.31067],
    zoom: 12
  })
});

const MapScene = React.memo(function Map() {
  
  function handlescene (scene){
    scene.on('mouseover',()=>{
    const drawLine = new DrawLine(scene,{editEnable:false,selectEnable:false,style:{
      normal: {
        line: {
          type: 'LineLayer',
          shape: 'line',
          size: 0,
          color: '#fff',
          style: {
            opacity: 0,
            stroke: '#fff',
            strokeWidth: 0
          },
        },     
      },
    }});
    try{
      drawLine.enable();
    }catch(e){}
    
  });
  };
  
  return (
    <React.Fragment>  
    <AMapScene
      map={{
        center: [ 110.19382669582967, 50.258134 ],
        pitch: 0,
        style: 'dark',
        zoom: 1,
      }}
      style={{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 0
      }}
      onSceneLoaded={scene => {
            handlescene(scene);
          }}
    />
    <Button >aa</Button>
    </React.Fragment>
  );
});


ReactDOM.render(<MapScene/>, document.getElementById('map'));

这样,在图上任意一处完成绘制后,就会得到如下报错
err