首页 / 浏览问题 / WebGIS / 问题详情
通过MapVlayer添加的图层需要怎么移除或者隐藏
12EXP 2025年09月02日
// 飞线点
const flyDian = () => {
  const lineDataSet = new mapv.DataSet(lineData)

  const lineOptions = {
    strokeStyle: 'rgba(255, 250, 50, 0.8)',
    shadowColor: 'rgba(255, 250, 50, 1)',
    shadowBlur: 20,
    lineWidth: 2,
    zIndex: 100,
    draw: 'simple'
  }
  new L.supermap.MapVLayer(lineDataSet, lineOptions).addTo(pageData.map)

  const pointOptions = {
    fillStyle: 'rgba(254,175,3,0.7)',
    shadowColor: 'rgba(55, 50, 250, 0.5)',
    shadowBlur: 10,
    size: 5,
    zIndex: 10,
    draw: 'simple'
  }

  const pointDataSet = new mapv.DataSet(pointData)
  // 点
  new L.supermap.MapVLayer(pointDataSet, pointOptions).addTo(pageData.map)

  const timeDataSet = new mapv.DataSet(timeData)

  const timeOptions = {
    fillStyle: 'rgba(255, 250, 250, 0.5)',
    zIndex: 200,
    size: 2.5,
    animation: {
      type: 'time',
      stepsRange: {
        start: 0,
        end: 50
      },
      trails: 10,
      duration: 2
    },
    draw: 'simple'
  }
  // 动画效果
  new L.supermap.MapVLayer(timeDataSet, timeOptions).addTo(pageData.map)
}

我是使用这种方式添加的飞线点位等,我下钻的时候截取了当前省份,当前省份外的地图不显示,但是这个飞线和点位一直在,如何给他移除或者隐藏

1个回答

您好,

MapVLayer图层可以使用MapVLayer.remove()方法隐藏,但隐藏后无法再使用addTo(map)方法显示,因此如果想要直接移除可以使用这个方法;

如果隐藏后还需要显示,可以使用mapVLayer.clearData()实现隐藏,再次显示使用以下代码:

let dataCache = mapVLayer.dataSet._dataCache
mapVLayer.addData(dataCache)

希望能够帮助到您。
275EXP 2025年09月03日
...