plot_plotGOAnimation.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html xmlns="http://www.w3.org/1999/html">
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_plotGOAnimation"></title>
  9. <style type="text/css">
  10. #map {
  11. position: absolute;
  12. left: 250px;
  13. right: 0px;
  14. height: 100%;
  15. }
  16. #plottingPanel {
  17. float: left;
  18. background: #ffffff;
  19. width: 250px;
  20. height: 100%;
  21. border: 1px solid #3473b7;
  22. }
  23. #plottingMenu {
  24. position: absolute;
  25. top: 20%;
  26. z-index: 999999;
  27. border-radius: 4px;
  28. padding-top: 2px;
  29. left: 265px;
  30. color: #000000;
  31. background-color: #fff;
  32. }
  33. </style>
  34. </head>
  35. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  36. <div id="toolbar" class="panel panel-primary"
  37. style=" position: absolute;top: 15px;right: 20px;text-align: center;z-index: 2000;border-radius: 4px;">
  38. <div class="panel-heading" id="panelheading">
  39. <h5 class="panel-title text-center" data-i18n="resources.title_plotGOAnimation" style=" font-size: 16px;color: #ffffff;"></h5>
  40. </div>
  41. <div class="panel-body content" id="panelbodycontent">
  42. <div class="input-group" style="margin-top:15px; margin-left: 10px; margin-bottom: 10px;">
  43. <select class="search-query form-control" id="SLT" data-i18n="[style]resources.style_plotAnimation"></select>&nbsp;&nbsp;
  44. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_createAnimation" onclick="createAnimation()">&nbsp;&nbsp;
  45. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_play" onclick="play()">&nbsp;&nbsp;
  46. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_pause" onclick="pause()">&nbsp;&nbsp;
  47. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_stop" onclick="stop()">&nbsp;&nbsp;
  48. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_reset" onclick="reset()">&nbsp;&nbsp;
  49. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_deleteAnimation" onclick="deleteSelectedFeaturesAnimation()">&nbsp;&nbsp;
  50. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_deleteAllAnimation" onclick="deleteAllAnimation()">&nbsp;&nbsp;
  51. </div>
  52. </div>
  53. </div>
  54. <div id="plottingPanel">
  55. <div class="easyui-panel" style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;">
  56. <div class="easyui-tabs" style="width: 100%;height: 100%">
  57. <div id="plotPanel" data-i18n="[title]resources.text_drawPanel" style="overflow: hidden"></div>
  58. <div id="stylePanel" data-i18n="[title]resources.text_attributePanel"></div>
  59. </div>
  60. </div>
  61. </div>
  62. <div id="plottingMenu" class="sticklr">
  63. <li>
  64. <a class="glyphicon plotting-glyphicon-draw-deactivate notArrow"
  65. data-i18n="[title]resources.text_cancelDraw"
  66. onclick="cancelDraw()"></a>
  67. </li>
  68. <li>
  69. <a class="glyphicon plotting-glyphicon-draw-removeAll notArrow"
  70. data-i18n="[title]resources.text_input_value_clear"></a>
  71. <ul>
  72. <li><input type="button" data-i18n="[value]resources.btn_deleteMarker" onclick="deleteSymbol()"
  73. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  74. <li><input type="button" data-i18n="[value]resources.btn_clearLayers" onclick="clearLayer()"
  75. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  76. </ul>
  77. </li>
  78. <li>
  79. <a class="glyphicon plotting-lyphicon-save-simulationMap"
  80. data-i18n="[title]resources.text_situationMapOperation"></a>
  81. <ul>
  82. <li><input type="button" data-i18n="[value]resources.btn_saveSimulationMap" onclick="saveSimulationMap()"
  83. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  84. <li><input type="button" data-i18n="[value]resources.btn_loadSimulationMap" onclick="loadSimulationMap()"
  85. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  86. </ul>
  87. </li>
  88. </div>
  89. <div id="map"></div>
  90. <script type="text/javascript" include="bootstrap,sticklr,plottingPanel" src="../js/include-web.js"></script>
  91. <script type="text/javascript" include="iclient-plot-leaflet"
  92. src="../../dist/leaflet/include-leaflet.js"></script>
  93. <script type="text/javascript" include="PlotPanel,StylePanel"
  94. src="../js/plottingPanel/PlottingPanel.Include.js"></script>
  95. <script type="text/javascript">
  96. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  97. var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
  98. var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
  99. var map;
  100. var item = [resources.text_attrAnimation, resources.text_flickerAnimation, resources.text_growthAnimation, resources.text_revolveAnimation, resources.text_proportionAnimation, resources.text_SHAnimation, resources.text_pathAnimation],
  101. select, animationtype;
  102. map = L.map('map', {
  103. preferCanvas: true,
  104. crs: L.CRS.EPSG4326,
  105. center: [35, 104],
  106. maxZoom: 18,
  107. zoom: 3
  108. });
  109. L.supermap.tiledMapLayer(url).addTo(map);
  110. var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
  111. plottingLayer.spatialAnalystUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  112. plottingLayer.addTo(map);
  113. var drawControl = L.supermap.plotting.drawControl(plottingLayer);
  114. drawControl.addTo(map);
  115. var editControl = L.supermap.plotting.editControl();
  116. editControl.addTo(map);
  117. L.supermap.plotting.initPlotPanel("plotPanel", serverUrl, drawControl);
  118. L.supermap.plotting.initStylePanel("stylePanel", serverUrl, editControl);
  119. var plotting = L.supermap.plotting.getControl(map, serverUrl);
  120. var goAnimationManager = plotting.getGOAnimationManager();
  121. window.setInterval("execute()", 100);
  122. initHtml();
  123. loadSmlAndAnimation();
  124. function initHtml(){
  125. select = document.getElementById("SLT");
  126. for (var i = 0, len = item.length; i < len; i++) {
  127. var options = document.createElement("option");
  128. options.setAttribute("value", item[i]);
  129. options.innerHTML = item[i];
  130. select.appendChild(options);
  131. }
  132. }
  133. function loadSmlAndAnimation(){
  134. $.getJSON("../data/ZaoYiHuiZhan_Sml.json",function(sitData){
  135. plotting.getSitDataManager().openSmlData(sitData, true);
  136. plottingLayer = plotting.getSitDataManager().getSitDataLayers()[0];
  137. drawControl.setDrawingLayer(plottingLayer);
  138. $.getJSON("../data/ZaoYiHuiZhan_Animation.json",function(animationJsonData){
  139. goAnimationManager.fromJSONData(animationJsonData);
  140. });
  141. });
  142. }
  143. //保存态势图
  144. function saveSimulationMap() {
  145. cancelDraw();
  146. plotting.getSitDataManager().saveAsSmlFile("situationMap");
  147. }
  148. function loadSimulationMap() {
  149. plotting.getSitDataManager().openSmlFileOnServer("situationMap", function (evt) {
  150. drawControl.setDrawingLayer(evt.sitDataLayers[0]);
  151. });
  152. }
  153. //取消标绘
  154. function cancelDraw() {
  155. drawControl.handler.disable();
  156. }
  157. //删除选中标号
  158. function deleteSymbol() {
  159. editControl.deleteSelectedFeatures();
  160. }
  161. //清空绘制
  162. function clearLayer() {
  163. cancelDraw();
  164. for (var i = 0; i < map.getPlottingLayers().length; i++) {
  165. map.getPlottingLayers()[i].removeAllFeatures();
  166. }
  167. }
  168. //播放动画
  169. function play() {
  170. if (null === goAnimationManager.goAnimations) {
  171. return;
  172. }
  173. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  174. goAnimationManager.goAnimations[i].play();
  175. }
  176. }
  177. //暂停
  178. function pause() {
  179. if (null === goAnimationManager.goAnimations) {
  180. return;
  181. }
  182. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  183. goAnimationManager.goAnimations[i].pause();
  184. }
  185. }
  186. //停止
  187. function stop() {
  188. if (null === goAnimationManager.goAnimations) {
  189. return;
  190. }
  191. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  192. goAnimationManager.goAnimations[i].stop();
  193. }
  194. }
  195. //复位
  196. function reset() {
  197. if (null === goAnimationManager.goAnimations) {
  198. return;
  199. }
  200. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  201. goAnimationManager.goAnimations[i].reset();
  202. }
  203. }
  204. function execute() {
  205. goAnimationManager.execute();
  206. }
  207. function deleteSelectedFeaturesAnimation() {
  208. if (null === goAnimationManager.goAnimations) {
  209. return;
  210. }
  211. if (0 === editControl.getSelectedFeatures().length) {
  212. return;
  213. }
  214. var selectFeature = editControl.getSelectedFeatures()[0];
  215. var animations = goAnimationManager.findGOAnimationsByFeature(selectFeature);
  216. for (var i = 0; i < animations.length; i++) {
  217. goAnimationManager.removeGOAnimation(animations[i]);
  218. }
  219. }
  220. function deleteAllAnimation() {
  221. if (null === goAnimationManager.goAnimations) {
  222. return;
  223. }
  224. goAnimationManager.reset();
  225. goAnimationManager.removeAllGOAnimation();
  226. }
  227. //创建动画
  228. function createAnimation() {
  229. if (0 === editControl.getSelectedFeatures().length) {
  230. return;
  231. }
  232. var obj = selectAnimationType();
  233. var feature = editControl.getSelectedFeatures()[0];
  234. var goAnimationNameUUid = SuperMap.Plot.PlottingUtil.generateUuid();
  235. var goAnimationName = obj.selectValue + goAnimationNameUUid;
  236. var goAnimation = goAnimationManager.createGOAnimation(obj.animationType, goAnimationName, feature);
  237. switch (goAnimation.getGOAnimationType()) {
  238. case SuperMap.Plot.GOAnimationType.ANIMATION_ATTRIBUTE:
  239. {//属性动画
  240. // goAnimation.startTime=0;//开始时间
  241. // goAnimation.duration=5;//间隔时间
  242. //goAnimation.repeat = true;//重复播放
  243. goAnimation.lineColorAnimation = true;//线色动画
  244. goAnimation.startLineColor = "#ff0000";//开始线色
  245. goAnimation.endLineColor = "#1a1817";//结束线色
  246. goAnimation.lineWidthAnimation = true;//线宽动画
  247. goAnimation.startLineWidth = 1;//开始线宽
  248. goAnimation.endLineWidth = 5;//结束线宽
  249. goAnimation.surroundLineColorAnimation = true;//衬线动画
  250. goAnimation.startSurroundLineColor = "#ffff00";//开始衬线色
  251. goAnimation.endSurroundLineColor = "#009933";//结束衬线色
  252. goAnimation.surroundLineWidthAnimation = true;//衬线宽
  253. goAnimation.startSurroundLineWidth = 2;//开始衬线宽
  254. goAnimation.endSurroundLineWidth = 4;//结束衬线宽
  255. break;
  256. }
  257. case SuperMap.Plot.GOAnimationType.ANIMATION_BLINK:
  258. {//闪烁动画
  259. // goAnimation.startTime = 5;
  260. // goAnimation.duration = 5;
  261. //goAnimation.repeat = true;//重复播放
  262. //闪烁类型:次数闪烁
  263. goAnimation.blinkStyle = SuperMap.Plot.BlinkAnimationBlinkStyle.Blink_Number;
  264. goAnimation.blinkNumber = 5;//闪烁次数
  265. //闪烁类型:频率闪烁
  266. //goAnimation.blinkStyle = SuperMap.Plot.BlinkAnimationBlinkStyle.Blink_Frequency;
  267. //goAnimation.blinkInterval = 500;//闪烁频率
  268. //闪烁颜色交替类型:无颜色交替
  269. //goAnimation.replaceStyle = SuperMap.Plot.BlinkAnimationReplaceStyle.Replace_NoColor;
  270. //闪烁颜色交替类型:有颜色交替
  271. goAnimation.replaceStyle = SuperMap.Plot.BlinkAnimationReplaceStyle.Replace_Color;
  272. goAnimation.startColor = "#00ff00";
  273. goAnimation.endColor = "#ff0000";
  274. break;
  275. }
  276. case SuperMap.Plot.GOAnimationType.ANIMATION_GROW:
  277. {//生长动画
  278. // goAnimation.startTime =10;
  279. // goAnimation.duration = 5;
  280. //goAnimation.repeat = true;
  281. goAnimation.startScale = 0;
  282. goAnimation.endScale = 1;
  283. break;
  284. }
  285. case SuperMap.Plot.GOAnimationType.ANIMATION_ROTATE:
  286. {//旋转动画
  287. // goAnimation.startTime = 15;
  288. // goAnimation.duration = 5;
  289. //goAnimation.repeat = true;
  290. goAnimation.rotateDirection = SuperMap.Plot.RotateDirection.AntiClockWise;//逆时针旋转
  291. //goAnimation.rotateDirection = SuperMap.Plot.RotateDirection.ClockWise;//顺时针旋转
  292. goAnimation.startAngle = 0;
  293. goAnimation.endAngle = 90;
  294. break;
  295. }
  296. case SuperMap.Plot.GOAnimationType.ANIMATION_SCALE:
  297. {//比例动画
  298. // goAnimation.startTime = 20;
  299. // goAnimation.duration = 5;
  300. //goAnimation.repeat = true;
  301. goAnimation.startScale = 1;
  302. goAnimation.endScale = 2;
  303. break;
  304. }
  305. case SuperMap.Plot.GOAnimationType.ANIMATION_SHOW:
  306. {//显隐动画
  307. // goAnimation.startTime=25;//开始时间
  308. // goAnimation.duration=5;//间隔时间
  309. //goAnimation.repeat = true;//重复播放
  310. goAnimation.finalDisplay = true;
  311. goAnimation.showEffect = true;
  312. break;
  313. }
  314. case SuperMap.Plot.GOAnimationType.ANIMATION_WAY:
  315. {//路径动画
  316. // goAnimation.startTime = 30;//开始时间
  317. // goAnimation.duration = 5;//间隔时间
  318. //goAnimation.repeat = true;//是否重复播放
  319. var arypts = [];
  320. var pt = L.latLng(44, 88);
  321. var pt1 = L.latLng(30, 91);
  322. var pt2 = L.latLng(37, 102);
  323. var pt3 = L.latLng(30, 106);
  324. var pt4 = L.latLng(34, 109);
  325. var pt5 = L.latLng(35, 114);
  326. var pt6 = L.latLng(40, 116);
  327. arypts.push(pt);
  328. arypts.push(pt1);
  329. arypts.push(pt2);
  330. arypts.push(pt3);
  331. arypts.push(pt4);
  332. arypts.push(pt5);
  333. arypts.push(pt6);
  334. goAnimation.setWayPoints(arypts);
  335. //路径类型:折线类型
  336. goAnimation.pathType = SuperMap.Plot.WayPathType.POLYLINE;
  337. //路径类型:曲线路径
  338. //goAnimation.pathType=SuperMap.Plot.WayPathType.CURVE;
  339. goAnimation.pathColor = "#005eff";
  340. goAnimation.pathWidth = 3;
  341. //是否是切线方向
  342. goAnimation.tangentDirection = true;
  343. goAnimation.setShowPath(true);
  344. break;
  345. }
  346. }
  347. }
  348. function selectAnimationType() {
  349. var select = document.getElementById("SLT");
  350. var type;
  351. for (var i = 0; i < select.children.length; i++) {
  352. if (select.children[i].selected) {
  353. type = select.children[i].value;
  354. }
  355. }
  356. //item=["属性动画","闪烁动画","生长动画","旋转动画","比例动画","显隐动画","路径动画"]
  357. if (type === item[0]) {
  358. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_ATTRIBUTE;
  359. }
  360. else if (type === item[1]) {
  361. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_BLINK;
  362. }
  363. else if (type === item[2]) {
  364. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_GROW;
  365. }
  366. else if (type === item[3]) {
  367. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_ROTATE;
  368. }
  369. else if (type === item[4]) {
  370. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_SCALE;
  371. }
  372. else if (type === item[5]) {
  373. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_SHOW;
  374. }
  375. else if (type === item[6]) {
  376. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_WAY;
  377. }
  378. var obj = new Object();
  379. obj.selectValue = type;
  380. obj.animationType = animationtype;
  381. return obj;
  382. }
  383. $(document).ready(function(){
  384. $('#panelheading').click(function(){
  385. $('#panelbodycontent').toggle();
  386. });
  387. });
  388. </script>
  389. </body>
  390. </html>