From 25ce610f6ecca7325e7a743dc032c4a76559c63d Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Fri, 02 Jul 2021 09:10:26 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/pyhmap

---
 widgets/digTheEarth/Widget.js |   79 +++++++++++++--------------------------
 1 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/widgets/digTheEarth/Widget.js b/widgets/digTheEarth/Widget.js
index 2501555..4cafa8e 100644
--- a/widgets/digTheEarth/Widget.js
+++ b/widgets/digTheEarth/Widget.js
@@ -27,7 +27,10 @@
                     that.closesDigTheEarth();
                 })
 
-                // that.beginDigTheEarth();
+                $("#beginigTheEarth").click(() => {
+                    that.beginDigTheEarth();
+
+                })
             },
             beginDigTheEarth: function () {
                 var that = this
@@ -49,50 +52,9 @@
                 //         roll: 6.2831853016686185
                 //     }
                 // });
-                function createTooltip(frameDiv) {//抄录createTooltip函数
 
-                    var tooltip = function (frameDiv) {
-
-                        var div = document.createElement('DIV');
-                        div.className = "twipsy right";
-
-                        var arrow = document.createElement('DIV');
-                        arrow.className = "twipsy-arrow";
-                        div.appendChild(arrow);
-
-                        var title = document.createElement('DIV');
-                        title.className = "twipsy-inner";
-                        div.appendChild(title);
-
-                        this._div = div;
-                        this._title = title;
-                        this.message = '';
-
-                        // add to frame div and display coordinates
-                        frameDiv.appendChild(div);
-                        var that = this;
-                        div.onmousemove = function (evt) {
-                            that.showAt({ x: evt.clientX, y: evt.clientY }, that.message);
-                        };
-                    };
-
-                    tooltip.prototype.setVisible = function (visible) {
-                        this._div.style.display = visible ? 'block' : 'none';
-                    };
-
-                    tooltip.prototype.showAt = function (position, message) {
-                        if (position && message) {
-                            this.setVisible(true);
-                            this._title.innerHTML = message;
-                            this._div.style.left = position.x + 10 + "px";
-                            this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
-                            this.message = message;
-                        }
-                    };
-
-                    return new tooltip(frameDiv);
-                }
-                var tooltip = createTooltip(viewer._element);
+                var tooltip = window.MYcreateTooltip(viewer._element);
+                // console.log(viewer._element, 534)
                 //绘制多边形
                 var handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0);
                 handlerPolygon.activeEvt.addEventListener(function (isActive) {
@@ -107,6 +69,9 @@
                     }
                 });
                 handlerPolygon.movingEvt.addEventListener(function (windowPosition) {
+                    // console.log(windowPosition,534)
+                    // console.log(handlerPolygon.isDrawing,555)
+                    // console.log(viewer._element, 534)
                     if (windowPosition.x < 200 && windowPosition.y < 150) {
                         tooltip.setVisible(false);
                         return;
@@ -156,15 +121,17 @@
                 });
                 handlerPolygon.activate();
                 document.getElementById("cleardigTheEarth").onclick = function () {
-                    viewer.scene.globe.removeAllExcavationRegion();
-                    if (handlerPolygon.polygon) {
-                        handlerPolygon.polygon.show = false;
-                    }
-                    if (handlerPolygon.polyline) {
-                        handlerPolygon.polyline.show = false;
-                    }
+                    // viewer.scene.globe.removeAllExcavationRegion();
+                    // if (handlerPolygon.polygon) {
+                    //     handlerPolygon.polygon.show = false;
+                    // }
+                    // if (handlerPolygon.polyline) {
+                    //     handlerPolygon.polyline.show = false;
+                    // }
                     // handlerPolygon.polygon.show = false;
                     // handlerPolygon.polyline.show = false;
+
+                    that.closesDigTheEarth();
                 };
 
                 if (!scene.pickPositionSupported) {
@@ -173,8 +140,10 @@
                 $('#toolbardigTheEarth').show();
                 $('#loadingbar').remove();
                 that.handlerPolygon = handlerPolygon;
+                that.tooltip = tooltip;
             },
             handlerPolygon: '',
+            tooltip: '',
             closesDigTheEarth: function () {
                 // console.log('gaunbi');
                 var that = this;
@@ -185,8 +154,12 @@
                 if (that.handlerPolygon.polyline) {
                     that.handlerPolygon.polyline.show = false;
                 }
-                that.handlerPolygon.deactivate();
-
+                if (that.handlerPolygon.deactivate) {
+                    that.handlerPolygon.deactivate();
+                }
+                if(that.tooltip.setVisible){
+                    that.tooltip.setVisible(false);
+                }
             },
             onOpen: function () {
 

--
Gitblit v1.9.3