Просмотр исходного кода

Fixed - 2.5D地图选择功能优化

彭宇 3 дней назад
Родитель
Сommit
14390e0957
2 измененных файлов с 340 добавлено и 342 удалено
  1. 2 5
      public/index.html
  2. 338 337
      src/components/supermap-2.5d.vue

+ 2 - 5
public/index.html

@@ -276,13 +276,10 @@
 <script src="hk/jsWebControl-1.0.0.min.js"></script>   <!-- 用于前端与插件交互 -->
 <!--<script src="h5player/h5player.min.js"></script>-->
 
-<script type="text/javascript" src="/SuperMap3D/examples/webgl/js/jquery.min.js"></script>
-<script type="text/javascript" src="/SuperMap3D/build/SuperMap3D.js"></script>
+<!--<script type="text/javascript" src="/SuperMap3D/examples/webgl/js/jquery.min.js"></script>-->
+<script type="text/javascript" src="/SuperMap3D/SuperMap3D.js"></script>
 <script type="text/javascript" src="/SuperMap3D/examples/webgl/js/tooltip.js"></script>
 
-<!--<script type="text/javascript" src="/SuperMap3D/examples/webgl/js/jquery.min.js"></script>-->
-<!--<script type="text/javascript" src="/SuperMap3D/build/SuperMap3D.js"></script>-->
-<!--<script type="text/javascript" src="/SuperMap3D/examples/webgl/js/tooltip.js"></script>-->
 
 
 <!--  <link rel="stylesheet" href="./supermap/libs/plotting/leaflet/10.2.1/iclient-plot-leaflet.css">-->

+ 338 - 337
src/components/supermap-2.5d.vue

@@ -1399,362 +1399,363 @@ export default {
         if (!urlList.length) return;  // 如果没有 URL,跳过当前迭代  // 如果没有 URL,跳过当前迭代
         SuperMap3D.when.all(that.selectMapObj_3D(urlList[0]), function (layers) {
           layersAll.push(layers)
-        });
-      });
-      if (layersAll.length === 0) {
-        return
-      }
-      that.showSoxSelection= true
-      /**
-       * @param dom ScreenSpaceEventHandler操作的dom节点,画的框会成为其子节点
-       */
-      function DrawRectHandler(dom) {
-        let startPoint,
-          self = this,
-          isShiftAndLeftDown = false,
-          removalFunctions = [],
-          rect = new Rect(dom)
-
-        that.handlerBoxSelection = new SuperMap3D.ScreenSpaceEventHandler(dom)
-        this.isDestroyed = false
-        this.activeEvt = new SuperMap3D.Event()
-        this.cancelEvt = new SuperMap3D.Event()
-        this.movingEvt = new SuperMap3D.Event()
-        this.drawEvt = new SuperMap3D.Event()
-
-        // div框
-        function Rect(parentDom) {
-          this.rect = document.createElement('div')
-          this.rect.style.visibility = 'hidden'
-          parentDom.appendChild(this.rect)
-          this.leftTopPoint = new SuperMap3D.Cartesian2()
-          this.rightBottomPoint = new SuperMap3D.Cartesian2()
-          Rect.prototype.setPosition = function (startPoint, endPosition) {
-            let w = endPosition.x - startPoint.x
-            let h = endPosition.y - startPoint.y
-            let left, top, width, height
-            if (w < 0) {
-              left = endPosition.x
-              width = -w
-            } else {
-              left = startPoint.x
-              width = w
-            }
-            if (h < 0) {
-              top = endPosition.y
-              height = -h
-            } else {
-              top = startPoint.y
-              height = h
-            }
-            this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
-            this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
-            this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
-            this.setVisible(true)
-          }
-          Rect.prototype.setVisible = function (isVisible) {
-            this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
-          }
-          Rect.prototype.getRectPoint = function () {
-            return {
-              leftTopPoint: this.leftTopPoint,
-              rightBottomPoint: this.rightBottomPoint
-            }
-          }
-          Rect.prototype.destroy = function () {
-            dom.removeChild(rect)
-            this.rect = null
-          }
-        }
-
-        // canvas框
-        function RectCanvas(parentDom) {
-          let canvas = document.createElement('canvas'),
-            ctx = canvas.getContext('2d')
-          this.canvas = canvas
-          canvas.width = parentDom.clientWidth
-          canvas.height = parentDom.clientHeight
-          canvas.style = 'position:fixed;top:0;left:0;z-index:-1'
-          parentDom.appendChild(canvas)
-          this.leftTopPoint = new SuperMap3D.Cartesian2()
-          this.rightBottomPoint = new SuperMap3D.Cartesian2()
-          RectCanvas.prototype.setPosition = function (startPoint, endPosition) {
-            let w = endPosition.x - startPoint.x
-            let h = endPosition.y - startPoint.y
-            let left, top, width, height
-            if (w < 0) {
-              left = endPosition.x
-              width = -w
-            } else {
-              left = startPoint.x
-              width = w
-            }
-            if (h < 0) {
-              top = endPosition.y
-              height = -h
-            } else {
-              top = startPoint.y
-              height = h
-            }
-            this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
-            this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
-            ctx.clearRect(0, 0, canvas.width, canvas.height)
-            ctx.strokeRect(left, top, width, height)
-          }
-          RectCanvas.prototype.setVisible = function (isVisible) {
-            if (isVisible) {
-              canvas.style.zIndex = '999'
-            } else {
-              canvas.style.zIndex = '-1'
-            }
-          }
-          RectCanvas.prototype.getRectPoint = function () {
-            return {
-              leftTopPoint: this.leftTopPoint,
-              rightBottomPoint: this.rightBottomPoint
-            }
-          }
-          RectCanvas.prototype.destroy = function () {
-            dom.removeChild(canvas)
-            ctx = null
-            this.canvas = null
-          }
-        }
-
-        // 开关相机控制
-        function setCameraCtrl(isActive) {
-          let cameraCtrl = that.scene.screenSpaceCameraController
-          cameraCtrl.enableRotate = isActive
-          cameraCtrl.enableTranslate = isActive
-          cameraCtrl.enableZoom = isActive
-          cameraCtrl.enableTilt = isActive
-          cameraCtrl.enableLook = isActive
-        }
-
-        // 鼠标cursor控制
-        function toggleCursorStyle(isActive) {
-          if (isActive) {
-            that.viewer.enableCursorStyle = false
-            that.viewer._element.style.cursor = ''
-            dom.style.cursor = 'default'
-          } else {
-            that.viewer.enableCursorStyle = true
-          }
-        }
-
-        // 初始化事件处理
-        function initEvent() {
-          that.handlerBoxSelection.setInputAction(function (e) {
-            isShiftAndLeftDown = true
-            startPoint = new SuperMap3D.Cartesian2(e.position.x, e.position.y)
-          }, SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
-          // shift松开时,始终将rect隐藏
-          let keyUpFunction = function (e) {
-            self.cancelEvt.raiseEvent()
-            if (e.key == 'Shift' && isShiftAndLeftDown && !self.isDestroyed) {
-              isShiftAndLeftDown = false
-              rect.setVisible(false)
-            }
-          }
-
-          document.addEventListener('keyup', keyUpFunction)
-          removalFunctions.push(function () {
-            document.removeEventListener('keyup', keyUpFunction)
-          })
-          that.handlerBoxSelection.setInputAction(function (e) {
-            let endPosition = e.endPosition
-            self.activeEvt.raiseEvent(endPosition)
-            if (!isShiftAndLeftDown) return
-            rect.setPosition(startPoint, endPosition)
-            rect.setVisible(true)
-            self.movingEvt.raiseEvent(rect.getRectPoint())
-          }, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
-          that.handlerBoxSelection.setInputAction(function (e) {
-            isShiftAndLeftDown = false
-            rect.setVisible(false)
-            self.drawEvt.raiseEvent(rect.getRectPoint())
-          }, SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
-          that.handlerBoxSelection.setInputAction(function (e) {
-            isShiftAndLeftDown = false
-            rect.setVisible(false)
-          }, SuperMap3D.ScreenSpaceEventType.LEFT_UP)
-        }
+          if (layersAll.length === 0) {
+            return
+          }else{
+            that.showSoxSelection= true
+            /**
+             * @param dom ScreenSpaceEventHandler操作的dom节点,画的框会成为其子节点
+             */
+            function DrawRectHandler(dom) {
+              let startPoint,
+                self = this,
+                isShiftAndLeftDown = false,
+                removalFunctions = [],
+                rect = new Rect(dom)
+
+              that.handlerBoxSelection = new SuperMap3D.ScreenSpaceEventHandler(dom)
+              this.isDestroyed = false
+              this.activeEvt = new SuperMap3D.Event()
+              this.cancelEvt = new SuperMap3D.Event()
+              this.movingEvt = new SuperMap3D.Event()
+              this.drawEvt = new SuperMap3D.Event()
+
+              // div框
+              function Rect(parentDom) {
+                this.rect = document.createElement('div')
+                this.rect.style.visibility = 'hidden'
+                parentDom.appendChild(this.rect)
+                this.leftTopPoint = new SuperMap3D.Cartesian2()
+                this.rightBottomPoint = new SuperMap3D.Cartesian2()
+                Rect.prototype.setPosition = function (startPoint, endPosition) {
+                  let w = endPosition.x - startPoint.x
+                  let h = endPosition.y - startPoint.y
+                  let left, top, width, height
+                  if (w < 0) {
+                    left = endPosition.x
+                    width = -w
+                  } else {
+                    left = startPoint.x
+                    width = w
+                  }
+                  if (h < 0) {
+                    top = endPosition.y
+                    height = -h
+                  } else {
+                    top = startPoint.y
+                    height = h
+                  }
+                  this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
+                  this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
+                  this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
+                  this.setVisible(true)
+                }
+                Rect.prototype.setVisible = function (isVisible) {
+                  this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
+                }
+                Rect.prototype.getRectPoint = function () {
+                  return {
+                    leftTopPoint: this.leftTopPoint,
+                    rightBottomPoint: this.rightBottomPoint
+                  }
+                }
+                Rect.prototype.destroy = function () {
+                  dom.removeChild(rect)
+                  this.rect = null
+                }
+              }
 
-        // 移除事件监听
-        function removeEvent() {
-          that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
-          that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
-          that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
-          that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
-        }
+              // canvas框
+              function RectCanvas(parentDom) {
+                let canvas = document.createElement('canvas'),
+                  ctx = canvas.getContext('2d')
+                this.canvas = canvas
+                canvas.width = parentDom.clientWidth
+                canvas.height = parentDom.clientHeight
+                canvas.style = 'position:fixed;top:0;left:0;z-index:-1'
+                parentDom.appendChild(canvas)
+                this.leftTopPoint = new SuperMap3D.Cartesian2()
+                this.rightBottomPoint = new SuperMap3D.Cartesian2()
+                RectCanvas.prototype.setPosition = function (startPoint, endPosition) {
+                  let w = endPosition.x - startPoint.x
+                  let h = endPosition.y - startPoint.y
+                  let left, top, width, height
+                  if (w < 0) {
+                    left = endPosition.x
+                    width = -w
+                  } else {
+                    left = startPoint.x
+                    width = w
+                  }
+                  if (h < 0) {
+                    top = endPosition.y
+                    height = -h
+                  } else {
+                    top = startPoint.y
+                    height = h
+                  }
+                  this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
+                  this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
+                  ctx.clearRect(0, 0, canvas.width, canvas.height)
+                  ctx.strokeRect(left, top, width, height)
+                }
+                RectCanvas.prototype.setVisible = function (isVisible) {
+                  if (isVisible) {
+                    canvas.style.zIndex = '999'
+                  } else {
+                    canvas.style.zIndex = '-1'
+                  }
+                }
+                RectCanvas.prototype.getRectPoint = function () {
+                  return {
+                    leftTopPoint: this.leftTopPoint,
+                    rightBottomPoint: this.rightBottomPoint
+                  }
+                }
+                RectCanvas.prototype.destroy = function () {
+                  dom.removeChild(canvas)
+                  ctx = null
+                  this.canvas = null
+                }
+              }
 
-        DrawRectHandler.prototype.destroy = function () {
-          if (this.isDestroyed) return
-          setCameraCtrl(true)
-          removeEvent()
-          for (let i = 0, j = removalFunctions.length; i < j; i++) {
-            removalFunctions[i]()
-          }
-          that.handlerBoxSelection.destroy()
-          rect.destroy()
-          rect = null
-          this.isDestroyed = true
-        }
-        DrawRectHandler.prototype.activate = function () {
-          if (this.isDestroyed) return
-          setCameraCtrl(false)
-          toggleCursorStyle(true)
-          initEvent()
-        }
-        DrawRectHandler.prototype.deactivate = function () {
-          if (this.isDestroyed) return
-          setCameraCtrl(true)
-          toggleCursorStyle(false)
-          that.boxSelectionTooltip.setVisible(false)
-          removeEvent()
-        }
-      }
-      // div框
-      function Rect(parentDom) {
-        this.rect = document.createElement('div')
-        this.rect.style.visibility = 'hidden'
-        parentDom.appendChild(this.rect)
-        this.leftTopPoint = new SuperMap3D.Cartesian2()
-        this.rightBottomPoint = new SuperMap3D.Cartesian2()
-        Rect.prototype.setPosition = function (startPoint, endPosition) {
-          let w = endPosition.x - startPoint.x
-          let h = endPosition.y - startPoint.y
-          let left, top, width, height
-          if (w < 0) {
-            left = endPosition.x
-            width = -w
-          } else {
-            left = startPoint.x
-            width = w
-          }
-          if (h < 0) {
-            top = endPosition.y
-            height = -h
-          } else {
-            top = startPoint.y
-            height = h
-          }
-          this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
-          this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
-          this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
-          this.setVisible(true)
-        }
-        Rect.prototype.setVisible = function (isVisible) {
-          this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
-        }
-        Rect.prototype.getRectPoint = function () {
-          return {
-            leftTopPoint: this.leftTopPoint,
-            rightBottomPoint: this.rightBottomPoint
-          }
-        }
-        Rect.prototype.destroy = function () {
-          dom.removeChild(rect)
-          this.rect = null
-        }
-      }
-      setTimeout(function() {
-        that.boxSelectionTooltip = createTooltip(document.body);
-          $('#loadingbar').remove();
+              // 开关相机控制
+              function setCameraCtrl(isActive) {
+                let cameraCtrl = that.scene.screenSpaceCameraController
+                cameraCtrl.enableRotate = isActive
+                cameraCtrl.enableTranslate = isActive
+                cameraCtrl.enableZoom = isActive
+                cameraCtrl.enableTilt = isActive
+                cameraCtrl.enableLook = isActive
+              }
 
-        for (let layers of layersAll) {
-          for (let layer of layers) {
-            layer.selectColorType = 1;
-            that.boxSelectionObjects.selectedObjs[layer.name] = [];
-          }
-        }
+              // 鼠标cursor控制
+              function toggleCursorStyle(isActive) {
+                if (isActive) {
+                  that.viewer.enableCursorStyle = false
+                  that.viewer._element.style.cursor = ''
+                  dom.style.cursor = 'default'
+                } else {
+                  that.viewer.enableCursorStyle = true
+                }
+              }
 
-          let drawRect = new DrawRectHandler(document.body);
+              // 初始化事件处理
+              function initEvent() {
+                that.handlerBoxSelection.setInputAction(function (e) {
+                  isShiftAndLeftDown = true
+                  startPoint = new SuperMap3D.Cartesian2(e.position.x, e.position.y)
+                }, SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
+                // shift松开时,始终将rect隐藏
+                let keyUpFunction = function (e) {
+                  self.cancelEvt.raiseEvent()
+                  if (e.key == 'Shift' && isShiftAndLeftDown && !self.isDestroyed) {
+                    isShiftAndLeftDown = false
+                    rect.setVisible(false)
+                  }
+                }
 
-          drawRect.drawEvt.addEventListener(function (res) {
+                document.addEventListener('keyup', keyUpFunction)
+                removalFunctions.push(function () {
+                  document.removeEventListener('keyup', keyUpFunction)
+                })
+                that.handlerBoxSelection.setInputAction(function (e) {
+                  let endPosition = e.endPosition
+                  self.activeEvt.raiseEvent(endPosition)
+                  if (!isShiftAndLeftDown) return
+                  rect.setPosition(startPoint, endPosition)
+                  rect.setVisible(true)
+                  self.movingEvt.raiseEvent(rect.getRectPoint())
+                }, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
+                that.handlerBoxSelection.setInputAction(function (e) {
+                  isShiftAndLeftDown = false
+                  rect.setVisible(false)
+                  self.drawEvt.raiseEvent(rect.getRectPoint())
+                }, SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
+                that.handlerBoxSelection.setInputAction(function (e) {
+                  isShiftAndLeftDown = false
+                  rect.setVisible(false)
+                }, SuperMap3D.ScreenSpaceEventType.LEFT_UP)
+              }
 
-            that.boxSelectionTooltip.setVisible(false);
+              // 移除事件监听
+              function removeEvent() {
+                that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_DOWN, SuperMap3D.KeyboardEventModifier.SHIFT)
+                that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE, SuperMap3D.KeyboardEventModifier.SHIFT)
+                that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP, SuperMap3D.KeyboardEventModifier.SHIFT)
+                that.handlerBoxSelection.removeInputAction(SuperMap3D.ScreenSpaceEventType.LEFT_UP)
+              }
 
-            let selectedColor = new SuperMap3D.Color(1, 0, 0, 1);
-            that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
-            that.scene.getPickRectIDsAsync().then(objs=>{
-              let selectedObjs = that.boxSelectionObjects.selectedObjs;
-              for (let k in selectedObjs) {
-                if (selectedObjs[k] !== undefined && selectedObjs[k] !== null && selectedObjs[k].length>0) {
-                  that.scene.layers.find(k).removeObjsColor(selectedObjs[k]);
+              DrawRectHandler.prototype.destroy = function () {
+                if (this.isDestroyed) return
+                setCameraCtrl(true)
+                removeEvent()
+                for (let i = 0, j = removalFunctions.length; i < j; i++) {
+                  removalFunctions[i]()
                 }
+                that.handlerBoxSelection.destroy()
+                rect.destroy()
+                rect = null
+                this.isDestroyed = true
+              }
+              DrawRectHandler.prototype.activate = function () {
+                if (this.isDestroyed) return
+                setCameraCtrl(false)
+                toggleCursorStyle(true)
+                initEvent()
+              }
+              DrawRectHandler.prototype.deactivate = function () {
+                if (this.isDestroyed) return
+                setCameraCtrl(true)
+                toggleCursorStyle(false)
+                that.boxSelectionTooltip.setVisible(false)
+                removeEvent()
               }
+            }
+            // div框
+            function Rect(parentDom) {
+              this.rect = document.createElement('div')
+              this.rect.style.visibility = 'hidden'
+              parentDom.appendChild(this.rect)
+              this.leftTopPoint = new SuperMap3D.Cartesian2()
+              this.rightBottomPoint = new SuperMap3D.Cartesian2()
+              Rect.prototype.setPosition = function (startPoint, endPosition) {
+                let w = endPosition.x - startPoint.x
+                let h = endPosition.y - startPoint.y
+                let left, top, width, height
+                if (w < 0) {
+                  left = endPosition.x
+                  width = -w
+                } else {
+                  left = startPoint.x
+                  width = w
+                }
+                if (h < 0) {
+                  top = endPosition.y
+                  height = -h
+                } else {
+                  top = startPoint.y
+                  height = h
+                }
+                this.leftTopPoint = new SuperMap3D.Cartesian2(left, top)
+                this.rightBottomPoint = new SuperMap3D.Cartesian2(left + width, top + height)
+                this.rect.style = `position:fixed;top:${top}px;left:${left}px;width:${width}px;height:${height}px;border:2px dashed #333;`
+                this.setVisible(true)
+              }
+              Rect.prototype.setVisible = function (isVisible) {
+                this.rect.style.visibility = isVisible ? 'visible' : 'hidden'
+              }
+              Rect.prototype.getRectPoint = function () {
+                return {
+                  leftTopPoint: this.leftTopPoint,
+                  rightBottomPoint: this.rightBottomPoint
+                }
+              }
+              Rect.prototype.destroy = function () {
+                dom.removeChild(rect)
+                this.rect = null
+              }
+            }
+            setTimeout(function() {
+              that.boxSelectionTooltip = createTooltip(document.body);
+              $('#loadingbar').remove();
+
               for (let layers of layersAll) {
                 for (let layer of layers) {
-                  let layerName = layer.name;
-                  let layerSlt = objs.find(e => e.layerName === layerName);
-                  let sltIds = (layerSlt && layerSlt.ids) || [];
-                  let lastIds = selectedObjs[layerName];
-                  switch (that.boxSelectionObjects.mode) {
-                    case 1:
-                      selectedObjs[layerName] = sltIds;
-                      break;
-                    case 2:
-                      selectedObjs[layerName] = _.union(lastIds, sltIds);;
-                      break;
-                    case 4:
-                      selectedObjs[layerName] = _.intersection(lastIds, sltIds);
-                      break;
-                    case 8:
-                      selectedObjs[layerName] = _.difference(lastIds, sltIds);
-                      break;
-                    default:
-                      break;
-                  }
-                  layer.setObjsColor(selectedObjs[layerName], selectedColor);
+                  layer.selectColorType = 1;
+                  that.boxSelectionObjects.selectedObjs[layer.name] = [];
                 }
               }
-              console.log('选择的数据:'+JSON.stringify(selectedObjs))
-            });
-          });
 
+              let drawRect = new DrawRectHandler(document.body);
 
-          drawRect.movingEvt.addEventListener(function (res) {
-            that.boxSelectionTooltip.showAt(res.rightBottomPoint,
-              '<p>松开鼠标左键以结束选择区域</p>'
-            );
-            if (that.boxSelectionObjects.isCallInMoving) {
-              for (let layer of layersAll) {
-                layer.selectColorType = 1;
-              }
-              that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
-            }
-          });
-          drawRect.activeEvt.addEventListener(function (position) {
-            that.boxSelectionTooltip.showAt(position,
-              '<p>点击鼠标左键以开始选择区域</p>'
-            );
-          });
+              drawRect.drawEvt.addEventListener(function (res) {
 
-          // $(document).keydown(function (e) {
-          //   if (e.key === 'Shift') {
-          //     drawRect.activate();
-          //   }
-          // })
-          $(document).keyup(function (e) {
-            if (e.key === 'Shift') {
-              drawRect.deactivate();
-            }
-          })
+                that.boxSelectionTooltip.setVisible(false);
 
-          $("#isCallInMoving").on("input change", function () {
-            that.boxSelectionObjects.isCallInMoving = that.checked;
-          });
-          $("#isSelection").click(function() {
-            drawRect.activate();
-          });
+                let selectedColor = new SuperMap3D.Color(1, 0, 0, 1);
+                that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
+                that.scene.getPickRectIDsAsync().then(objs=>{
+                  let selectedObjs = that.boxSelectionObjects.selectedObjs;
+                  for (let k in selectedObjs) {
+                    if (selectedObjs[k] !== undefined && selectedObjs[k] !== null && selectedObjs[k].length>0) {
+                      that.scene.layers.find(k).removeObjsColor(selectedObjs[k]);
+                    }
+                  }
+                  for (let layers of layersAll) {
+                    for (let layer of layers) {
+                      let layerName = layer.name;
+                      let layerSlt = objs.find(e => e.layerName === layerName);
+                      let sltIds = (layerSlt && layerSlt.ids) || [];
+                      let lastIds = selectedObjs[layerName];
+                      switch (that.boxSelectionObjects.mode) {
+                        case 1:
+                          selectedObjs[layerName] = sltIds;
+                          break;
+                        case 2:
+                          selectedObjs[layerName] = _.union(lastIds, sltIds);;
+                          break;
+                        case 4:
+                          selectedObjs[layerName] = _.intersection(lastIds, sltIds);
+                          break;
+                        case 8:
+                          selectedObjs[layerName] = _.difference(lastIds, sltIds);
+                          break;
+                        default:
+                          break;
+                      }
+                      layer.setObjsColor(selectedObjs[layerName], selectedColor);
+                    }
+                  }
+                  console.log('选择的数据:'+JSON.stringify(selectedObjs))
+                });
+              });
 
-          $("#mode").change(function (e) {
-            let mode = $("#mode").val();
-            that.boxSelectionObjects.mode = parseInt(mode);
-          });
 
-      }, 1000)
+              drawRect.movingEvt.addEventListener(function (res) {
+                that.boxSelectionTooltip.showAt(res.rightBottomPoint,
+                  '<p>松开鼠标左键以结束选择区域</p>'
+                );
+                if (that.boxSelectionObjects.isCallInMoving) {
+                  for (let layer of layersAll) {
+                    layer.selectColorType = 1;
+                  }
+                  that.scene.pickRect(res.leftTopPoint, res.rightBottomPoint);
+                }
+              });
+              drawRect.activeEvt.addEventListener(function (position) {
+                that.boxSelectionTooltip.showAt(position,
+                  '<p>点击鼠标左键以开始选择区域</p>'
+                );
+              });
+
+              // $(document).keydown(function (e) {
+              //   if (e.key === 'Shift') {
+              //     drawRect.activate();
+              //   }
+              // })
+              $(document).keyup(function (e) {
+                if (e.key === 'Shift') {
+                  drawRect.deactivate();
+                }
+              })
+
+              $("#isCallInMoving").on("input change", function () {
+                that.boxSelectionObjects.isCallInMoving = that.checked;
+              });
+              $("#isSelection").click(function() {
+                drawRect.activate();
+              });
+
+              $("#mode").change(function (e) {
+                let mode = $("#mode").val();
+                that.boxSelectionObjects.mode = parseInt(mode);
+              });
+
+            }, 1000)
+          }
+        });
+      });
     },
     //爆管分析
     pipeBurstAnalysis(){