From a77448eb072f10dd3827694140f87c3069b1dba4 Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期六, 07 十月 2023 11:14:40 +0800
Subject: [PATCH] 代码更新

---
 src/components/left/leftmenu.vue |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/src/components/left/leftmenu.vue b/src/components/left/leftmenu.vue
index 6639447..c5a6fbf 100644
--- a/src/components/left/leftmenu.vue
+++ b/src/components/left/leftmenu.vue
@@ -1019,6 +1019,118 @@
         }
       }
     },
+    initCluster(treeNode) {
+      this.$set(treeNode, "disabled", true);//缁檛reeNode娣诲姞disabled灞炴��
+
+      let that = this;
+      let imgUrl;
+      new Cesium.GeoJsonDataSource.load(
+        treeNode.urls +
+        "?version=1.3.0&request=GetFeature&format=json&typename=" +
+        treeNode.layer
+      ).then((dataSource) => {
+        that.$set(treeNode, "disabled", false);
+        Viewer.dataSources.add(dataSource);
+        clusterItemList.push({ name: treeNode.id, dataSource: dataSource });
+        // window.clusterItem = dataSource;
+        // 璁剧疆鑱氬悎鍙傛暟
+        // dataSource.clustering.enabled = true;
+        // window.dataClustering = dataSource.clustering;
+        // dataSource.clustering.pixelRange = 20;
+        // dataSource.clustering.minimumClusterSize = 20;
+
+        // foreach鐢ㄤ簬璋冪敤鏁扮粍鐨勬瘡涓厓绱狅紝骞跺皢鍏冪礌浼犻�掔粰鍥炶皟鍑芥暟銆�
+        dataSource.entities.values.forEach((entity) => {
+          // if (entity.featureType == "yz浜曟暟鎹�") {
+          //   switch (feature.properties["浜曠被鍨�"]) {
+          //     default:
+          //       imgUrl = treeNode.image;
+          //       break;
+          //   }
+          // }
+          // 灏嗙偣鎷変几涓�瀹氶珮搴︼紝闃叉琚湴褰㈠帇鐩�
+          // entity.position._value.z += 50.0;
+          // 浣跨敤澶у皬涓�64*64鐨刬con锛岀缉灏忓睍绀簆oi
+          entity.billboard = {
+            image: entity.featureType == "yz浜曟暟鎹�" ? imgUrl : treeNode.image,
+            scale: treeNode.imageScale,
+            // width: 50,
+            // height: 50,
+            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
+              0,
+              1000.0
+            ),
+            disableDepthTestDistance: Number.POSITIVE_INFINITY,
+          };
+          // entity.tag = treeNode.id;
+          // entity.label = {
+          //   // text: "POI",
+          //   font: "bold 15px Microsoft YaHei",
+          //   // 绔栫洿瀵归綈鏂瑰紡
+          //   verticalOrigin: Cesium.VerticalOrigin.CENTER,
+          //   // 姘村钩瀵归綈鏂瑰紡
+          //   horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
+          //   // 鍋忕Щ閲�
+          //   pixelOffset: new Cesium.Cartesian2(15, 0),
+          // };
+
+        });
+
+        // 娣诲姞鐩戝惉鍑芥暟
+        // dataSource.clustering.clusterEvent.addEventListener(function (
+        //   clusteredEntities,
+        //   cluster
+        // ) {
+        //   // 鍏抽棴鑷甫鐨勬樉绀鸿仛鍚堟暟閲忕殑鏍囩
+
+        //   cluster.label.show = true;
+        //   cluster.label.color = Cesium.Color.WHITE;
+        //   cluster.label.outlineColor = Cesium.Color.BLACK;
+        //   cluster.label.outlineWidth = 3.0;
+        //   cluster.label.style = Cesium.LabelStyle.FILL_AND_OUTLINE;
+        //   cluster.label.eyeOffset = new Cesium.Cartesian3(0, 0, -100);
+        //   cluster.label.disableDepthTestDistance = Number.POSITIVE_INFINITY;
+        //   cluster.billboard.disableDepthTestDistance = Number.POSITIVE_INFINITY;
+        //   cluster.billboard.show = true;
+        //   cluster.billboard.id = cluster.label.id;
+        //   cluster.billboard.horizontalOrigin = Cesium.HorizontalOrigin.LEFT;
+        //   cluster.billboard.verticalOrigin = Cesium.VerticalOrigin.CENTER;
+        //   var reg1 = new RegExp(",", "g");
+        //   cluster.label.text = cluster.label.text.replace(reg1, "");
+        //   // 鏍规嵁鑱氬悎鏁伴噺鐨勫灏戣缃笉鍚屽眰绾х殑鍥剧墖浠ュ強澶у皬
+        //   if (clusteredEntities.length >= 10000) {
+        //     cluster.billboard.image = require("@/assets/img/right/test01.png");
+        //     cluster.billboard.pixelOffset = new Cesium.Cartesian2(-25, -10);
+        //     cluster.billboard.width = 142;
+        //     cluster.billboard.height = 142;
+        //   } else if (clusteredEntities.length >= 1000) {
+        //     cluster.billboard.image = require("@/assets/img/right/test01.png");
+        //     cluster.billboard.pixelOffset = new Cesium.Cartesian2(-35, -10);
+
+        //     cluster.billboard.width = 135;
+        //     cluster.billboard.height = 135;
+        //   } else if (clusteredEntities.length >= 100) {
+        //     cluster.billboard.image = require("@/assets/img/right/test01.png");
+        //     cluster.billboard.pixelOffset = new Cesium.Cartesian2(-26, -10);
+
+        //     cluster.billboard.width = 102;
+        //     cluster.billboard.height = 102;
+        //   }
+
+        //   else if (clusteredEntities.length >= 10) {
+        //     cluster.billboard.image = require("@/assets/img/right/test04.png");
+        //     cluster.billboard.pixelOffset = new Cesium.Cartesian2(-25, -10);
+        //     cluster.billboard.width = 82;
+        //     cluster.billboard.height = 82;
+        //   } else {
+        //     cluster.billboard.image = require("@/assets/img/right/test04.png");
+        //     cluster.billboard.pixelOffset = new Cesium.Cartesian2(-25, -10);
+        //     cluster.billboard.width = 62;
+        //     cluster.billboard.height = 62;
+        //   }
+        // });
+      });
+    },
     async addTreeData(treeNode) {
       // if (treeNode.disabled) return;
       let _data = sgworld.ProjectTree.getObject(treeNode.id);
@@ -1274,6 +1386,10 @@
           );
           treeNode.id = layer.treeobj.id;
           break;
+
+        case "cluster":
+          layer = this.initCluster(treeNode);
+          break;
         case "yztile":
           layer = new YZWMS(treeNode);
           sgworld._Viewer.imageryLayers.addImageryProvider(layer);

--
Gitblit v1.9.3