时序动画

补充1:2019-08-29

发布服务前,设置时区

02.png

效果图:
01.png

步骤一:数据准备

拖拉机数据:时间2019/6/7 7:59:00-2019/6/713:52:00
目标数据:时间2019/6/7 8:00:00-2019/6/713:52:00

注意:所有的数据需放在地理数据库里,否则日期后的时分秒被自动截去删除。

步骤二:制图表达

将拖拉机数据转为制图表达,重新为RULEID赋值,这里我全赋值为6,不能赋值为0哦。
目标数据线分为五个等级,再转为制图表达,RULEID是否重新赋值视情况而定。(能够满足步骤四的分级)

步骤三:合并merge

将两个制图表达数据合并。

步骤四:分级

将步骤三合并的文件进行分级,这里分为六级(包括整个图层),其中第六级用来渲染拖拉机符号。

步骤五:再次制图表达

将分级后的文件再次制作制图表达,对第六级进行符号渲染。

步骤六:将文件导入到数据库

步骤七:从数据库拉去数据设置timeslider属性,发布服务

步骤八:调用服务

使用动态图层,要素服务调用,符号不渲染。

完整代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Recent Earthquakes</title>

<link rel="stylesheet" href="https://js.arcgis.com/3.29/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.29/esri/css/esri.css">

<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
.dijitBorders{
margin:5px 5px 5px 5px;
border:solid thin #9CAA9C;
-moz-border-radius: 4px;
}
.labelText{
color:#9CAA9C;
font-size:12pt;
font-family:"Tahoma";
margin:5px;
}
.headerText{
color:#9CAA9C;
font-size:16pt;
font-weight:bold;
font-family: "Tahoma";
}
</style>

<script src="https://js.arcgis.com/3.29/"></script>
<script>
var map,timeExtent;
require([
"esri/map","esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/FeatureLayer", "esri/TimeExtent", "esri/layers/TimeInfo",
"esri/renderers/ClassBreaksRenderer",
"esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol",
"esri/dijit/editing/TemplatePicker", "esri/dijit/TimeSlider",
"esri/renderers/TimeClassBreaksAger", "esri/renderers/TemporalRenderer",
"dojo/parser", "dojo/_base/array", "esri/Color", "dojo/dom", "dojo/date",

"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
], function(
Map, ArcGISDynamicMapServiceLayer,FeatureLayer, TimeExtent, TimeInfo,
ClassBreaksRenderer,
SimpleMarkerSymbol, SimpleLineSymbol,
TemplatePicker, TimeSlider,
TimeClassBreaksAger, TemporalRenderer,
parser, arrayUtils, Color, dom, date
) {
parser.parse();

map = new Map("map", {
basemap: "satellite",
center: [114.0143, 34.11075],
slider: false,
zoom:15
});
//边界
var research_scope = new ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/Henan_S/research_scope1/MapServer",{"id":"100000"});
map.on("load", mapLoaded);

function mapLoaded() {
var SOMtlj = new ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/Henan_S/PH1_TLJ/MapServer",{"id":"3"});
SOMtlj.on("load", featureLayerLoaded);
map.addLayer(SOMtlj);
map.addLayer(research_scope);
}

function featureLayerLoaded() {
// create time slider
var timeSlider = new TimeSlider({ style: "width: 100%;"}, dom.byId("timeSliderDiv"));
map.setTimeSlider(timeSlider);

timeExtent = new TimeExtent();

// 设置时区后,开始时间和结束时间
//timeExtent.startTime = new Date("2019/06/06 23:59:00 UTC");
//timeExtent.endTime = new Date("2019/06/07 05:52:00 UTC");

timeSlider.setThumbCount(1);
timeSlider.createTimeStopsByTimeInterval(timeExtent, 1, "esriTimeUnitsMinutes");

timeSlider.setThumbIndexes([0]);
timeSlider.on("time-extent-change", displayTimeInfo);
timeSlider.startup();
// timeSlider.play();
}

function displayTimeInfo(timeExtent) {
var info = timeExtent.endTime;
dom.byId("timeInfo").innerHTML = info;
}

});
</script>
</head>

<body class="claro">
<div id="mainWindow"
data-dojo-type="dijit/layout/BorderContainer"
data-dojo-propx="design:'sidebar', gutters:true"
style="width:100%; height:100%;">
<div id="header"
data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'top'"
class="dijitBorders" style="height:100px;">
<center>
<span class="headerText">采样时序</span>
<div id="timeInfo" class="labelText"></div>
<div id="timeSliderDiv" ></div>
</center>
</div>

<div id="map" data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'center'" class="dijitBorders"
style="background-color:inherit;">
</div>

<div id="right" data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'left'"
style="width:100px;font-size:small;">

<center><span class="labelText">Age</span></center>
<div id="ageDiv" class="dijitBorders"></div>
<center><span class="labelText">Magnitude</span></center>
<div id="magnitudeDiv" class="dijitBorders" ></div>
</div>

</div>
</body>
</html>