From d74b495736f0c04522ec54274b70fed0ded2878d Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 27 Jun 2023 11:30:06 +0800
Subject: [PATCH] 任务新增导出
---
public/map/controls/timeslider/TimeSliderControl.js | 135 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 135 insertions(+), 0 deletions(-)
diff --git a/public/map/controls/timeslider/TimeSliderControl.js b/public/map/controls/timeslider/TimeSliderControl.js
new file mode 100644
index 0000000..8a93417
--- /dev/null
+++ b/public/map/controls/timeslider/TimeSliderControl.js
@@ -0,0 +1,135 @@
+/**
+ * 时间轴widget
+ * @author Liuyl
+ * @date 2015/10/15
+ */
+define([
+ "dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang",
+ "dojo/dom", "dojo/dom-style", "dojo/dom-class", "dojo/dom-attr", "dojo/dom-construct",
+ "dojo/topic",
+ "dijit/_WidgetBase", "dijit/_TemplatedMixin",
+ "dojo/text!controls/timeslider/TimeSliderControl.html",
+ "base/BaseControl", "base/AppEvent",
+ "utils/LayerUtil",
+ "controls/timeslider/js/jquery.ui.timeslider"
+], function(
+ declare, arrayUtil, lang,
+ dom, domStyle, domClass, domAttr, domConstruct,
+ topic,
+ _WidgetBase, _TemplatedMixin,
+ template,
+ BaseControl, AppEvent,
+ LayerUtil
+) {
+ var Widget = declare("TimeSliderControl", [BaseControl], {
+ templateString: template,
+ baseClass: "timeslider-base",
+ constructor: function(options) {
+ this.index = {};
+
+ AppEvent.addAppEventListener(AppEvent.SWITCH_BASEMAP, lang.hitch(this, function(evt) {
+ if(this.id == evt.sender){
+ return;
+ }
+ if (evt.hockId != this.hockId)
+ return;
+ if (this.curGroupId == evt.grouplayer && this.curSetId == evt.setlayer) {
+ return;
+ }
+ var groupid = evt.grouplayer;
+
+ if(evt.setlayer){
+ setid = evt.setlayer;
+ }else{
+ //根据时间查找Group中的layerset是否有时间,没有的话设为默认
+ setid = this.index[groupid]["defaultset"];
+ arrayUtil.forEach(Object.keys(this.index[groupid]), lang.hitch(this, function(key) {
+ if(key!="defaultset"&&key!="slider"&&setid==this.index[groupid][key]){
+ this.index[groupid].slider.timeslider("setCurrent", parseInt(key));
+ }
+ }));
+
+ arrayUtil.forEach(Object.keys(this.index[groupid]), lang.hitch(this, function(key) {
+ if (key!="defaultset"&&key!="slider"&&this._parseResult.groups[groupid].layerset[this.index[groupid][key]].label == this._parseResult.groups[this.curGroupId].layerset[this.curSetId].label) {
+ this.index[groupid].slider.timeslider("setCurrent", parseInt(key));
+ setid = this.index[groupid][key];
+ }
+
+ }));
+ }
+ domStyle.set(this.index[this.curGroupId].slider[0], "display", "none");
+ domStyle.set(this.index[groupid].slider[0], "display", "block");
+ var curIndex = this.index[groupid].slider.timeslider("getCurrent");
+// if (this.index[groupid][curIndex] != setid) {
+// arrayUtil.forEach(Object.keys(this.index[groupid]), lang.hitch(this, function(key) {
+// if (key!="defaultset"&&this.index[groupid][key] == setid) {
+// this.index[groupid].slider.timeslider("setCurrent", parseInt(key));
+// }
+// }));
+// }
+
+ this.curGroupId = groupid;
+ this.curSetId = this.index[groupid][curIndex];
+
+ }));
+ },
+ startup: function() {
+ try {
+ this.inherited(arguments);
+ this.curGroupId = this.visibleGroupLayerId;
+ this.curSetId = this.visibleSetLayerId;
+ this._parseResult = LayerUtil.parseGroups(this.grouplayersConfig);
+ this.groups = this._parseResult.groupsInOrder;
+ arrayUtil.forEach(this.groups, lang.hitch(this, function(group, index) {
+ this.index[group] = {};
+ var sliderDom = domConstruct.create("div", {
+ "groupid": group,
+ className: "timeslider_container"
+ }, this.domNode);
+ domStyle.set(sliderDom, "display", "none");
+ var timeset = [];
+ //var setCount = this._parseResult.groups[group].layersetInOrder.length;
+ var curIndex = 0;
+ arrayUtil.forEach(this._parseResult.groups[group].layersetInOrder, lang.hitch(this, function(set, index) {
+ var layerset=this._parseResult.groups[group].layerset[set];
+ timeset[index] = layerset.label;
+ this.index[group][index] = layerset.id;
+ if (this.curSetId == layerset.id) {
+ curIndex = index;
+ }
+ }));
+ $(sliderDom).timeslider({
+ groupName:this._parseResult.groups[group].label,
+ timeset: timeset,
+ max: timeset.length,
+ min: 0,
+ reverse: true,
+ timeChangeHandler: lang.hitch(this, function(index) {
+ var setid = this.index[this.curGroupId][index];
+ this.curSetId = setid;
+ AppEvent.dispatchAppEvent(AppEvent.SWITCH_BASEMAP, {
+ hockId: this.hockId,
+ grouplayer: this.curGroupId,
+ setlayer: setid,
+ sender:this.id
+ });
+ })
+ });
+ this.index[group].slider = $(sliderDom);
+ this.index[group].defaultset = this._parseResult.groups[group].defaultset;
+ $(sliderDom).timeslider("setCurrent", curIndex);
+ }));
+ domStyle.set(this.index[this.curGroupId].slider[0], "display", "block");
+ } catch (err) {
+ console.log(err);
+ }
+ },
+ show: function() {
+ domStyle.set(this.domNode, "display", "block");
+ },
+ hide: function() {
+ domStyle.set(this.domNode, "display", "none");
+ }
+ });
+ return Widget;
+});
\ No newline at end of file
--
Gitblit v1.9.3