From 85bcf0300cfbdfbd518e380b8f8dc09445e0c1f8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 05 Jun 2021 14:50:12 +0800
Subject: [PATCH] 部分接口的端口更换,卷帘对比的核对,完善卷帘对比功能

---
 widgets/Rolling/Widget.js |  199 +++++++++++++++++++++----------------------------
 1 files changed, 84 insertions(+), 115 deletions(-)

diff --git a/widgets/Rolling/Widget.js b/widgets/Rolling/Widget.js
index c9f9b9b..ec040f5 100644
--- a/widgets/Rolling/Widget.js
+++ b/widgets/Rolling/Widget.js
@@ -1,11 +1,11 @@
 define([
-    'dojo/_base/declare',
-    'dojo/_base/lang',
-    'dojo/_base/array',
-    'dojo/_base/html',
-    'dojo/topic',
-    'jimu/BaseWidget',
-],
+        'dojo/_base/declare',
+        'dojo/_base/lang',
+        'dojo/_base/array',
+        'dojo/_base/html',
+        'dojo/topic',
+        'jimu/BaseWidget',
+    ],
     function (declare,
         lang,
         array,
@@ -37,12 +37,6 @@
                 "tileMatrixSetID": "w",
                 "maximumLevel": 17
             }],
-            // 赣州地图
-            imageryProviderArrUrl: [{
-                "label": "赣州市离线影像",
-                "type": "url",
-                "url": "http://www.sw797.com:801/gzsw3D/v2/data/wp/{z}/{x}/{y}.png"
-            }],
             // 天地图电子
             imageryProviderDian: [{
                 "label": "天地图矢量",
@@ -67,57 +61,44 @@
             earthAtNightRight: '',
             zjLeft: 0,
             zjRight: '',
+
             tiandituLeft: '',
             tiandituZJLeft: '',
             tiandituRight: '',
             tiandituZJRight: '',
-            ganZhouYinLeft: '',
-            ganZhouYinRight: '',
+
             startup: function () {
                 topic.subscribe("openRolling", lang.hitch(this, this.openRolling));
                 var that = this;
                 // 点击卷帘关闭面板
                 $('.rollinng-table-hezi-xx').click(function () {
+
                     that.map.imageryLayers.remove(that.earthAtNightLeft);
-                    that.map.imageryLayers.remove(that.earthAtNightRight);
                     that.map.imageryLayers.remove(that.zjLeft);
+
+                    that.map.imageryLayers.remove(that.earthAtNightRight);
                     that.map.imageryLayers.remove(that.zjRight);
+                    
+                    
                     that.map.imageryLayers.remove(that.tiandituLeft);
                     that.map.imageryLayers.remove(that.tiandituZJLeft);
+
                     that.map.imageryLayers.remove(that.tiandituRight);
                     that.map.imageryLayers.remove(that.tiandituZJRight);
-                    that.map.imageryLayers.remove(that.ganZhouYinLeft);
-                    that.map.imageryLayers.remove(that.ganZhouYinRight);
+         
                     $('.jimu-widget-Rolling').hide();
-                    $('#hezi-selectLeft').val(2);
-                    $('#hezi-selectRight').val(3);
+                   
                 });
 
                 // 加载左边图层
                 $('#hezi-selectLeft').on('change', function () {
                     // 将滑块的位置与拆分位置同步
                     var slider = document.getElementById('slider');
-                    that.map.scene.imagerySplitPosition = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
+                    that.map.scene.imagerySplitPosition.x = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
                     if ($(this).val() == 2) {
-                        // viewer.imageryLayers.remove(that.tiandituLeft);
-                        // viewer.imageryLayers.remove(that.tiandituZJLeft);
-                        viewer.imageryLayers.remove(that.ganZhouYinLeft);
+                        loadMapTianLeft();
+                    } else if ($(this).val() == 1) {
                         loadMapLeft();
-                        that.earthAtNightLeft.splitDirection = Cesium.ImagerySplitDirection.LEFT;
-                        that.zjLeft.splitDirection = Cesium.ImagerySplitDirection.LEFT;
-                    }
-                    else if ($(this).val() == 1) {
-                        viewer.imageryLayers.remove(that.earthAtNightLeft);
-                        viewer.imageryLayers.remove(that.zjLeft);
-                        // viewer.imageryLayers.remove(that.tiandituLeft);
-                        // viewer.imageryLayers.remove(that.tiandituZJLeft);
-                        loadMapGzLeft();
-                        that.ganZhouYinLeft.splitDirection = Cesium.ImagerySplitDirection.LEFT;
-                    }
-                    else {
-                        viewer.imageryLayers.remove(that.earthAtNightLeft);
-                        viewer.imageryLayers.remove(that.zjLeft);
-                        viewer.imageryLayers.remove(that.ganZhouYinLeft);
                     }
                 });
 
@@ -126,135 +107,115 @@
                     // debugger
                     // 将滑块的位置与拆分位置同步
                     var slider = document.getElementById('slider');
-                    that.map.scene.imagerySplitPosition = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
+                    that.map.scene.imagerySplitPosition.x = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
                     if ($(this).val() == 2) {
                         // loadMap(that.earthAtNightRight, that.zjRight);
-                        viewer.imageryLayers.remove(that.tiandituRight);
-                        viewer.imageryLayers.remove(that.tiandituZJRight);
                         loadMapRight();
-                        that.earthAtNightRight.splitDirection = Cesium.ImagerySplitDirection.RIGHT;
-                        that.zjRight.splitDirection = Cesium.ImagerySplitDirection.RIGHT;
-                    }
-                    else if ($(this).val() == 3) {
-                        viewer.imageryLayers.remove(that.earthAtNightRight);
-                        viewer.imageryLayers.remove(that.zjRight);
+                    } else if ($(this).val() == 1) {
                         loadMapTianRight();
-                        that.tiandituRight.splitDirection = Cesium.ImagerySplitDirection.RIGHT;
-                        that.tiandituZJRight.splitDirection = Cesium.ImagerySplitDirection.RIGHT;
-                    }
-                    else {
-                        viewer.imageryLayers.remove(that.earthAtNightRight);
-                        viewer.imageryLayers.remove(that.zjRight);
-                        loadMapGzRight();
-                        that.ganZhouYinRight.splitDirection = Cesium.ImagerySplitDirection.RIGHT;
-                        // viewer.imageryLayers.remove(that.tiandituRight);
-                        // viewer.imageryLayers.remove(that.tiandituZJRight);
-                    }
+                    } 
                 });
-
 
                 // 加载左边天地图影像图层方法
                 function loadMapLeft() {
+                    that.map.imageryLayers.remove(that.tiandituLeft);
+                    that.map.imageryLayers.remove(that.tiandituZJLeft);
                     //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
                     //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中
-                    that.earthAtNightLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.earthAtNightLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderAdd[0]
                     ));
-                    that.zjLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.zjLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderAdd[1]
                     ));
-                }
 
-                // 加载左边赣州影像图层方法
-                function loadMapGzLeft() {
-                    //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
-                    //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中  UrlTemplateImageryProvider
-                    that.ganZhouYinLeft = layers.addImageryProvider(new Cesium.UrlTemplateImageryProvider(
-                        that.imageryProviderArrUrl[0]
-                    ));
+                    that.earthAtNightLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
+                    that.zjLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
                 }
 
                 // 加载左边天地图电子图层方法
                 function loadMapTianLeft() {
+                    that.map.imageryLayers.remove(that.earthAtNightLeft);
+                    that.map.imageryLayers.remove(that.zjLeft);
                     //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
                     //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中
-                    that.tiandituLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.tiandituLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderDian[0]
                     ));
-                    that.tiandituZJLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.tiandituZJLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderDian[1]
                     ));
+
+                    that.tiandituLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
+                    that.tiandituZJLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
                 }
+
 
                 // 加载右边天地图影像图层方法
                 function loadMapRight() {
+                    that.map.imageryLayers.remove(that.tiandituRight);
+                    that.map.imageryLayers.remove(that.tiandituZJRight);
                     //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
                     //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中
-                    that.earthAtNightRight = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.earthAtNightRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderAdd[0]
                     ));
-                    that.zjRight = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.zjRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderAdd[1]
                     ));
+                    that.earthAtNightRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
+                    that.zjRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
                 }
 
                 // 加载右边天地图电子图层方法
                 function loadMapTianRight() {
+                    that.map.imageryLayers.remove(that.earthAtNightRight);
+                    that.map.imageryLayers.remove(that.zjRight);
                     //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
                     //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中
-                    that.tiandituRight = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.tiandituRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderDian[0]
                     ));
-                    that.tiandituZJRight = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.tiandituZJRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
                         that.imageryProviderDian[1]
                     ));
+                    that.tiandituRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
+                    that.tiandituZJRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
                 }
 
-                 // 加载右边赣州影像图层方法
-                 function loadMapGzRight() {
-                    //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = viewer.imageryLayers;
-                    //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中  UrlTemplateImageryProvider
-                    that.ganZhouYinRight = layers.addImageryProvider(new Cesium.UrlTemplateImageryProvider(
-                        that.imageryProviderArrUrl[0]
-                    ));
-                }
 
                 var handler = new Cesium.ScreenSpaceEventHandler(slider);
 
                 var moveActive = false;
+
                 function move(movement) {
                     if (!moveActive) {
                         return;
                     }
                     var relativeOffset = movement.endPosition.x;
+
                     // 将滑块的位置与拆分位置同步
-                    viewer.scene.imagerySplitPosition = (slider.offsetLeft + relativeOffset - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
-                    slider.style.left = 100.0 * + (slider.offsetLeft + relativeOffset) / (slider.parentElement.offsetWidth) + '%';
+                    that.map.scene.imagerySplitPosition.x = (slider.offsetLeft + relativeOffset - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
+                    slider.style.left = 100.0 * +(slider.offsetLeft + relativeOffset) / (slider.parentElement.offsetWidth) + '%';
+
                 }
 
-
                 handler.setInputAction(function () {
                     moveActive = true;
-                }, Cesium.ScreenSpaceEventType.LEFT_DOWN);//左键按下事件
+                }, Cesium.ScreenSpaceEventType.LEFT_DOWN); //左键按下事件
                 handler.setInputAction(function () {
                     moveActive = true;
-                }, Cesium.ScreenSpaceEventType.PINCH_START);//触摸表面上双指事件的开始
+                }, Cesium.ScreenSpaceEventType.PINCH_START); //触摸表面上双指事件的开始
 
-                handler.setInputAction(move, Cesium.ScreenSpaceEventType.MOUSE_MOVE);//鼠标移动事件
-                handler.setInputAction(move, Cesium.ScreenSpaceEventType.PINCH_MOVE);//触摸表面上双指移动事件
+                handler.setInputAction(move, Cesium.ScreenSpaceEventType.MOUSE_MOVE); //鼠标移动事件
+                handler.setInputAction(move, Cesium.ScreenSpaceEventType.PINCH_MOVE); //触摸表面上双指移动事件
 
                 handler.setInputAction(function () {
                     moveActive = false;
-                }, Cesium.ScreenSpaceEventType.LEFT_UP);//鼠标左键抬起事件
+                }, Cesium.ScreenSpaceEventType.LEFT_UP); //鼠标左键抬起事件
                 handler.setInputAction(function () {
                     moveActive = false;
-                }, Cesium.ScreenSpaceEventType.PINCH_END);//触摸表面上的双指事件的结束
+                }, Cesium.ScreenSpaceEventType.PINCH_END); //触摸表面上的双指事件的结束
             },
 
             openRolling: function (item) {
@@ -268,23 +229,31 @@
                 var that = this;
                 if (this.flag != true) return;
                 var slider = document.getElementById('slider');
-                that.map.scene.imagerySplitPosition = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
-                that.map.scene.imagerySplitPosition = 0.5;
-                loadMapLeft();
-                that.earthAtNightLeft.splitDirection = Cesium.ImagerySplitDirection.LEFT;
-                that.zjLeft.splitDirection = Cesium.ImagerySplitDirection.LEFT;
+                that.map.scene.imagerySplitPosition.x = (slider.offsetLeft - slider.parentElement.offsetWidth) / (slider.parentElement.offsetWidth);
+                that.map.scene.imagerySplitPosition.x = 0.5;
 
-                function loadMapLeft() {
-                    //imageryLayers获取将在地球上渲染的图像图层的集合
-                    var layers = that.map.imageryLayers;
-                    //addImageryProvider使用给定的ImageryProvider创建一个新层,并将其添加到集合中
-                    that.earthAtNightLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
-                        that.imageryProviderAdd[0]
-                    ));
-                    that.zjLeft = layers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
-                        that.imageryProviderAdd[1]
-                    ));
-                }
+
+
+                that.earthAtNightLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.imageryProviderAdd[0]
+                ));
+                that.zjLeft = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.imageryProviderAdd[1]
+                ));
+
+                that.earthAtNightLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
+                that.zjLeft.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.LEFT, Cesium.ImagerySplitDirection.NONE);
+
+               
+                that.tiandituRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.imageryProviderDian[0]
+                ));
+                that.tiandituZJRight = that.map.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider(
+                    that.imageryProviderDian[1]
+                ));
+
+                that.tiandituRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
+                that.tiandituZJRight.splitDirection = new Cesium.Cartesian2(Cesium.ImagerySplitDirection.RIGHT, Cesium.ImagerySplitDirection.NONE);
             },
 
 

--
Gitblit v1.9.3