瀏覽代碼

修改传感器气泡

JX.LI 2 年之前
父節點
當前提交
67755d537a
共有 2 個文件被更改,包括 27 次插入3 次删除
  1. 26 2
      src/components/supermap-2.5d.vue
  2. 1 1
      src/views/monitor.vue

+ 26 - 2
src/components/supermap-2.5d.vue

@@ -5,7 +5,7 @@
       <div class="map-tit" v-show="mapshow">
         <div class="top-tit">
           <i class="iconfont sj-icon-jkzx"></i>
-          <span><img src="../assets/images/close.svg" @click="mapshow=false" /></span>
+          <span><img src="../assets/images/close.svg" @click="mapShow" /></span>
         </div>
         <div class="map-txt" v-html="bindPopupHtml">
         </div>
@@ -49,6 +49,7 @@
         connectBoxEntity: null, //地图线实体
         graphicsBoxEntity: null, //地图面实体
         connectBoxEntityTwo: null, //地图线实体
+        timer: null,
         /*************************原地图属性*********************/
         isEditableLayers: false, //绘图控件
 
@@ -68,6 +69,10 @@
     mounted() {},
     props: {},
     methods: {
+      mapShow() {
+        this.mapshow = false,
+          clearInterval(this.timer)
+      },
       //清除所有
       clearAll() {
         this.viewer.entities.removeAll()
@@ -298,14 +303,32 @@
               movement.position).primitive.id);
 
             let html = id._description;
-            if (html != undefined && html._value != null && html._value != '') {
+            clearInterval(that.timer)
+            if (html != undefined && html._value != null && html._value != '' && html != 'cgq') {
               that.bindPopupHtml = html
               that.mapshow = true
+            } else if (html == 'cgq') {
+              that.timer = setInterval(function() {
+                var color = "green";
+                var value = Math.random();
+                var up = "▲";
+                var down = "▼";
+                if (value > 0.5) {
+                  color = "red";
+                  value = value + "" + up;
+                } else {
+                  value = value + "" + down;
+                }
+                that.bindPopupHtml = "<span style='color:" + color + "'>当前传感器数值: " + value + "</span>";
+              }, 1000)
+              that.mapshow = true
             } else {
               that.mapshow = false
+              clearInterval(that.timer)
             }
           } else {
             that.mapshow = false
+            clearInterval(that.timer)
           }
         }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
       },
@@ -316,6 +339,7 @@
         let that = this;
         that.handler.setInputAction(function(movement) {
           that.mapshow = false
+          clearInterval(that.timer)
           // 监听鼠标的当前位置坐标,然后根据当前坐标去动态更新气泡窗口div的显示位置;
           that.pick = that.viewer.scene.pick(movement.position);
           if (that.pick && that.pick) {

+ 1 - 1
src/views/monitor.vue

@@ -473,7 +473,7 @@
                   lng: 124.59,
                   lat: 43.02,
                   icon: "marker",
-                  bindPopupHtml: "",
+                  bindPopupHtml: "cgq",
                   click: "",
                   parameter: "",
                   keepBindPopup: false,