guoshilong
2023-11-08 cad194dedbb5a0d9b376c1fe6053969d2098554e
src/hooks/use-cesium-tsa.ts
@@ -140,6 +140,10 @@
    }
  }
  function removeAllDataSource() {
    viewer.dataSources.removeAll();
  }
  // 清除所有标记点
  function removeAllPoint () {
    if (viewer) {
@@ -249,6 +253,22 @@
      viewer?.imageryLayers.addImageryProvider(annotation)
    }
  }
  //加载json文件
  const loadGeoJson = (url:string)=>{
    const option = {
      stroke: Cesium.Color.HOTPINK,
      fill: Cesium.Color.PINK,
      strokeWidth: 3,
    }
    const promise = Cesium.GeoJsonDataSource.load(url,option)
    promise.then(dataSource=>{
      console.log(dataSource)
      viewer.dataSources.add(dataSource);
    })
  }
  // 切换不同背景图层
  const patternMap = () => {
    const imageryLayers = viewer?.scene.imageryLayers
@@ -291,6 +311,8 @@
    patternMap,
    getEntityById,
    updateEntityPosition,
    addPolyline
    addPolyline,
    loadGeoJson,
    removeAllDataSource
  }
}