From cad194dedbb5a0d9b376c1fe6053969d2098554e Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 08 Nov 2023 15:53:24 +0800
Subject: [PATCH] 图斑加载
---
src/hooks/use-cesium-tsa.ts | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/src/hooks/use-cesium-tsa.ts b/src/hooks/use-cesium-tsa.ts
index 057c3e7..354e786 100644
--- a/src/hooks/use-cesium-tsa.ts
+++ b/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
}
}
--
Gitblit v1.9.3