plot_plotGOAnimation.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title data-i18n="resources.title_plotGOAnimation"></title>
  9. <style type="text/css">
  10. body {
  11. margin: 0;
  12. overflow: hidden;
  13. background: #fff;
  14. width: 100%;
  15. height: 100%
  16. }
  17. #map {
  18. position: absolute;
  19. left: 250px;
  20. right: 0px;
  21. width: 100%;
  22. height: 100%;
  23. }
  24. #toolbar {
  25. position: absolute;
  26. top: 50px;
  27. right: 10px;
  28. text-align: center;
  29. z-index: 100;
  30. border-radius: 4px;
  31. }
  32. #toolbar .panel-title {
  33. font-size: 16px;
  34. color: white;
  35. }
  36. #menu {
  37. position: absolute;
  38. background: #ffffff;
  39. width: 250px;
  40. height: 100%;
  41. border: 1px solid #3473b7;
  42. z-index: 100;
  43. }
  44. #menuPlotting {
  45. position: absolute;
  46. top: 40%;
  47. z-index: 999999;
  48. border-radius: 4px;
  49. padding-top: 2px;
  50. }
  51. .input-group {
  52. margin-bottom: 10px;
  53. }
  54. .panel-title {
  55. font-size: 16px;
  56. color: #ffffff;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <div id="toolbar" class="panel panel-primary">
  62. <div class='panel-heading'>
  63. <h5 class='panel-title text-center' data-i18n="resources.title_plotGOAnimation"></h5></div>
  64. <div class='panel-body content'>
  65. <div class='input-group' style="margin-top:15px;margin-left: 10px;">
  66. <select class="search-query form-control" id="SLT" data-i18n="[style]resources.style_plotAnimation"></select>&nbsp;&nbsp;
  67. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_createAnimation"
  68. onclick="createAnimation()"/>&nbsp;&nbsp;
  69. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_play" onclick="play()"/>&nbsp;&nbsp;
  70. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_pause" onclick="pause()"/>&nbsp;&nbsp;
  71. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_stop" onclick="stop()"/>&nbsp;&nbsp;
  72. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_reset" onclick="reset()"/>&nbsp;&nbsp;
  73. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_deleteAnimation"
  74. onclick="deleteSelectedFeaturesAnimation()"/>&nbsp;&nbsp;
  75. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_deleteAllAnimation"
  76. onclick="deleteAllAnimation()"/>&nbsp;&nbsp;
  77. </div>
  78. </div>
  79. </div>
  80. <div id="menu">
  81. <div class="easyui-panel" style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;">
  82. <div class="easyui-tabs" style="width: 100%;height: 100%">
  83. <div id="plotPanel" data-i18n="[title]resources.text_drawPanel" style="overflow: hidden"></div>
  84. <div id="stylePanel" data-i18n="[title]resources.text_attributePanel"></div>
  85. </div>
  86. </div>
  87. </div>
  88. <div id="map">
  89. <div id="menuPlotting" class="sticklr" style="left: 1%;color:rgb(0,0,0);background-color: #fff;">
  90. <li>
  91. <a class="glyphicon plotting-glyphicon-draw-deactivate notArrow"
  92. data-i18n="[title]resources.text_cancelDraw"
  93. onclick="PlottingDrawCancel()"></a>
  94. </li>
  95. <li>
  96. <a class="glyphicon plotting-glyphicon-draw-removeAll notArrow"
  97. data-i18n="[title]resources.text_input_value_clear"></a>
  98. <ul>
  99. <li><input type="button" data-i18n="[value]resources.btn_deleteMarker" onclick="deleteSymbol()"
  100. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  101. <li><input type="button" data-i18n="[value]resources.btn_clearLayers" onclick="PlottingClear()"
  102. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  103. </ul>
  104. </li>
  105. <li>
  106. <a class="glyphicon plotting-lyphicon-save-simulationMap"
  107. data-i18n="[title]resources.text_situationMapOperation"></a>
  108. <ul>
  109. <li><input type="button" data-i18n="[value]resources.btn_saveSimulationMap"
  110. onclick="saveSimulationMap()"
  111. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  112. <li><input type="button" data-i18n="[value]resources.btn_loadSimulationMap"
  113. onclick="loadSimulationMap()"
  114. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  115. </ul>
  116. </li>
  117. </div>
  118. </div>
  119. <script type="text/javascript" include="bootstrap,responsive,sticklr,widgets.alert" src="../js/include-web.js"></script>
  120. <script type="text/javascript" exclude="iclient-classic" include="iclient8c-plot,bevInclude,PlottingPanel"
  121. src="../../dist/classic/include-classic.js"></script>
  122. <script>
  123. var map, plottingLayer, layer;
  124. var plotPanel, stylePanel;
  125. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  126. var mapurl = host + "/iserver/services/map-china400/rest/maps/China_4326";
  127. var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
  128. var plotting;
  129. var sitDataLayers;
  130. var plottingEdit;
  131. var drawGraphicObjects = [];
  132. var item = [resources.text_attrAnimation, resources.text_flickerAnimation, resources.text_growthAnimation, resources.text_revolveAnimation, resources.text_proportionAnimation, resources.text_SHAnimation, resources.text_pathAnimation],
  133. select, animationtype;
  134. var goAnimationManager;
  135. init();
  136. function init() {
  137. if (!document.createElement('canvas').getContext) {
  138. widgets.alert.showAlert(resources.msg_supportCanvas, false);
  139. return;
  140. }
  141. Bev.Theme.set("bev-base");
  142. map = new SuperMap.Map("map", {
  143. controls: [
  144. new SuperMap.Control.LayerSwitcher(),
  145. new SuperMap.Control.ScaleLine(),
  146. new SuperMap.Control.Zoom(),
  147. new SuperMap.Control.Navigation({
  148. dragPanOptions: {
  149. enableKinetic: true
  150. }
  151. })]
  152. });
  153. layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", mapurl, {
  154. transparent: true,
  155. cacheEnabled: true
  156. }, {maxResolution: "auto"});
  157. layer.events.on({"layerInitialized": addLayer});
  158. //总控类
  159. plotting = SuperMap.Plotting.getInstance(map, serverUrl);
  160. plotting.getSitDataManager().events.on({"openSmlFileCompleted": success});
  161. plottingLayer = new SuperMap.Layer.PlottingLayer("标绘图层", serverUrl);
  162. //空间分析服务地址:目前使用的是服务器默认空间分析地址,可更换成实际使用的空间分析服务地址
  163. //plottingLayer.spatialAnalystUrl = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";
  164. plottingLayer.style = {
  165. fillColor: "#66cccc",
  166. fillOpacity: 0.4,
  167. strokeColor: "#66cccc",
  168. strokeOpacity: 1,
  169. strokeWidth: 3,
  170. pointRadius: 6
  171. };
  172. //态势标绘编辑
  173. plottingEdit = new SuperMap.Control.PlottingEdit();
  174. // 绘制标号;
  175. var drawGraphicObject = new SuperMap.Control.DrawFeature(plottingLayer, SuperMap.Handler.GraphicObject);
  176. drawGraphicObjects.push(drawGraphicObject);
  177. //添加态势标绘控件
  178. map.addControls([plottingEdit, drawGraphicObject]);
  179. }
  180. function addLayer() {
  181. map.addLayers([layer, plottingLayer]);
  182. map.setCenter(new SuperMap.LonLat(104, 35), 3);
  183. //创建标绘面板
  184. plotPanel = new SuperMap.Plotting.PlotPanel("plotPanel", serverUrl, map);
  185. plotPanel.events.on({"initializeCompleted": initializeCompleted});
  186. plotPanel.initializeAsync();
  187. //创建属性面板
  188. stylePanel = new SuperMap.Plotting.StylePanel("stylePanel");
  189. stylePanel.addEditLayer(plottingLayer);
  190. //设置动画管理器
  191. goAnimationManager = plotting.getGOAnimationManager();
  192. goAnimationManager.setMap(map);
  193. select = document.getElementById("SLT");
  194. for (var i = 0, len = item.length; i < len; i++) {
  195. var options = document.createElement("option");
  196. options.setAttribute("value", item[i]);
  197. options.innerHTML = item[i];
  198. select.appendChild(options);
  199. }
  200. //创建定时器,调用执行
  201. window.setInterval("execute()", 100);
  202. }
  203. function initializeCompleted(evt) {
  204. if (drawGraphicObjects.length > 0) {
  205. plotPanel.setDrawFeature(drawGraphicObjects[0]);
  206. }
  207. }
  208. //取消标绘与编辑
  209. function plottingAllDeactivate() {
  210. for (var i = 0; i < drawGraphicObjects.length; i++) {
  211. drawGraphicObjects[i].deactivate();
  212. }
  213. plottingEdit.deactivate();
  214. }
  215. //清空绘制
  216. function PlottingClear() {
  217. plottingAllDeactivate();
  218. for (var i = 0; i < map.layers.length; i++) {
  219. if (map.layers[i].CLASS_NAME === "SuperMap.Layer.PlottingLayer") {
  220. map.layers[i].removeAllFeatures();
  221. }
  222. }
  223. }
  224. //删除选中标号
  225. function deleteSymbol() {
  226. plottingEdit.deleteSelectFeature();
  227. }
  228. //取消标绘,激活标绘编辑控件
  229. function PlottingDrawCancel() {
  230. plottingAllDeactivate();
  231. plottingEdit.activate();
  232. }
  233. //保存态势图
  234. function saveSimulationMap() {
  235. plottingAllDeactivate();
  236. plotting.getSitDataManager().saveAsSmlFile("situationMap");
  237. }
  238. function loadSimulationMap() {
  239. {
  240. plotting.getSitDataManager().openSmlFileOnServer("situationMap");
  241. }
  242. }
  243. function success() {
  244. var sitDataLayers = plotting.getSitDataManager().getSitDataLayers();
  245. plottingLayer = sitDataLayers[0];
  246. drawGraphicObjects = [];
  247. for (var i = 0; i < sitDataLayers.length; i++) {
  248. drawGraphicObjects.push(sitDataLayers[i].drawGraphicObject);
  249. stylePanel.addEditLayer(sitDataLayers[i]);
  250. }
  251. plotPanel.setDrawFeature(drawGraphicObjects[0]);
  252. }
  253. //播放动画
  254. function play() {
  255. widgets.alert.clearAlert();
  256. if (null === goAnimationManager.goAnimations) {
  257. return;
  258. }
  259. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  260. goAnimationManager.goAnimations[i].play();
  261. }
  262. }
  263. //暂停
  264. function pause() {
  265. widgets.alert.clearAlert();
  266. if (null === goAnimationManager.goAnimations) {
  267. return;
  268. }
  269. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  270. goAnimationManager.goAnimations[i].pause();
  271. }
  272. }
  273. //停止
  274. function stop() {
  275. widgets.alert.clearAlert();
  276. if (null === goAnimationManager.goAnimations) {
  277. return;
  278. }
  279. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  280. goAnimationManager.goAnimations[i].stop();
  281. }
  282. }
  283. //复位
  284. function reset() {
  285. widgets.alert.clearAlert();
  286. if (null === goAnimationManager.goAnimations) {
  287. return;
  288. }
  289. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  290. goAnimationManager.goAnimations[i].reset();
  291. }
  292. }
  293. //创建动画
  294. function createAnimation() {
  295. widgets.alert.clearAlert();
  296. if (0 === stylePanel.selectFeatures.length) {
  297. return;
  298. }
  299. var obj = selectItem();
  300. var feature = stylePanel.selectFeatures[0];
  301. var goAnimationNameUUid = SuperMap.Plot.PlottingUtil.generateUuid();
  302. var goAnimationName = obj.selectValue + goAnimationNameUUid;
  303. var goAnimation = goAnimationManager.createGOAnimation(obj.animationType, goAnimationName, feature);
  304. switch (goAnimation.getGOAnimationType()) {
  305. case SuperMap.Plot.GOAnimationType.ANIMATION_ATTRIBUTE: {//属性动画
  306. //goAnimation.startTime=0;//开始时间
  307. //goAnimation.duration=5;//间隔时间
  308. //goAnimation.repeat = true;//重复播放
  309. goAnimation.lineColorAnimation = true;//线色动画
  310. goAnimation.startLineColor = "#ff0000";//开始线色
  311. goAnimation.endLineColor = "#1a1817";//结束线色
  312. goAnimation.lineWidthAnimation = true;//线宽动画
  313. goAnimation.startLineWidth = 1;//开始线宽
  314. goAnimation.endLineWidth = 5;//结束线宽
  315. goAnimation.surroundLineColorAnimation = true;//衬线动画
  316. goAnimation.startSurroundLineColor = "#ffff00";//开始衬线色
  317. goAnimation.endSurroundLineColor = "#009933";//结束衬线色
  318. goAnimation.surroundLineWidthAnimation = true;//衬线宽
  319. goAnimation.startSurroundLineWidth = 2;//开始衬线宽
  320. goAnimation.endSurroundLineWidth = 4;//结束衬线宽
  321. break;
  322. }
  323. case SuperMap.Plot.GOAnimationType.ANIMATION_BLINK: {//闪烁动画
  324. //goAnimation.startTime = 5;
  325. //goAnimation.duration = 5;
  326. //goAnimation.repeat = true;//重复播放
  327. //闪烁类型:次数闪烁
  328. goAnimation.blinkStyle = SuperMap.Plot.BlinkAnimationBlinkStyle.Blink_Number;
  329. goAnimation.blinkNumber = 5;//闪烁次数
  330. //闪烁类型:频率闪烁
  331. //goAnimation.blinkStyle = SuperMap.Plot.BlinkAnimationBlinkStyle.Blink_Frequency;
  332. //goAnimation.blinkInterval = 500;//闪烁频率
  333. //闪烁颜色交替类型:无颜色交替
  334. //goAnimation.replaceStyle = SuperMap.Plot.BlinkAnimationReplaceStyle.Replace_NoColor;
  335. //闪烁颜色交替类型:有颜色交替
  336. goAnimation.replaceStyle = SuperMap.Plot.BlinkAnimationReplaceStyle.Replace_Color;
  337. goAnimation.startColor = "#00ff00";
  338. goAnimation.endColor = "#ff0000";
  339. break;
  340. }
  341. case SuperMap.Plot.GOAnimationType.ANIMATION_GROW: {//生长动画
  342. //goAnimation.startTime =10;
  343. //goAnimation.duration = 5;
  344. //goAnimation.repeat = true;
  345. goAnimation.startScale = 0;
  346. goAnimation.endScale = 1;
  347. break;
  348. }
  349. case SuperMap.Plot.GOAnimationType.ANIMATION_ROTATE: {//旋转动画
  350. //goAnimation.startTime = 15;
  351. //goAnimation.duration = 5;
  352. //goAnimation.repeat = true;
  353. goAnimation.rotateDirection = SuperMap.Plot.RotateDirection.AntiClockWise;//逆时针旋转
  354. //goAnimation.rotateDirection = SuperMap.Plot.RotateDirection.ClockWise;//顺时针旋转
  355. goAnimation.startAngle = 0;
  356. goAnimation.endAngle = 90;
  357. break;
  358. }
  359. case SuperMap.Plot.GOAnimationType.ANIMATION_SCALE: {//比例动画
  360. //goAnimation.startTime = 20;
  361. //goAnimation.duration = 5;
  362. //goAnimation.repeat = true;
  363. goAnimation.startScale = 1;
  364. goAnimation.endScale = 2;
  365. break;
  366. }
  367. case SuperMap.Plot.GOAnimationType.ANIMATION_SHOW: {//显隐动画
  368. //goAnimation.startTime=25;//开始时间
  369. //goAnimation.duration=5;//间隔时间
  370. //goAnimation.repeat = true;//重复播放
  371. goAnimation.finalDisplay = true;
  372. goAnimation.showEffect = true;
  373. break;
  374. }
  375. case SuperMap.Plot.GOAnimationType.ANIMATION_WAY: {//路径动画
  376. //goAnimation.startTime = 30;//开始时间
  377. //goAnimation.duration = 5;//间隔时间
  378. //goAnimation.repeat = true;//是否重复播放
  379. var arypts = [];
  380. var pt = new SuperMap.Geometry.Point(88, 44);
  381. var pt1 = new SuperMap.Geometry.Point(91, 30);
  382. var pt2 = new SuperMap.Geometry.Point(102, 37);
  383. var pt3 = new SuperMap.Geometry.Point(106, 30);
  384. var pt4 = new SuperMap.Geometry.Point(109, 34);
  385. var pt5 = new SuperMap.Geometry.Point(114, 35);
  386. var pt6 = new SuperMap.Geometry.Point(116, 40);
  387. arypts.push(pt);
  388. arypts.push(pt1);
  389. arypts.push(pt2);
  390. arypts.push(pt3);
  391. arypts.push(pt4);
  392. arypts.push(pt5);
  393. arypts.push(pt6);
  394. goAnimation.setWayPoints(arypts);
  395. //路径类型:折线类型
  396. goAnimation.pathType = SuperMap.Plot.WayPathType.POLYLINE;
  397. //路径类型:曲线路径
  398. //goAnimation.pathType=SuperMap.Plot.WayPathType.CURVE;
  399. goAnimation.pathColor = "#005eff";
  400. goAnimation.pathWidth = 3;
  401. //是否是切线方向
  402. goAnimation.tangentDirection = true;
  403. goAnimation.setShowPath(true);
  404. break;
  405. }
  406. }
  407. }
  408. function selectItem() {
  409. var select = document.getElementById("SLT");
  410. var type;
  411. for (var i = 0; i < select.children.length; i++) {
  412. if (select.children[i].selected) {
  413. type = select.children[i].value;
  414. }
  415. }
  416. //item=["属性动画","闪烁动画","生长动画","旋转动画","比例动画","显隐动画","路径动画"]
  417. if (type === item[0]) {
  418. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_ATTRIBUTE;
  419. }
  420. else if (type === item[1]) {
  421. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_BLINK;
  422. }
  423. else if (type === item[2]) {
  424. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_GROW;
  425. }
  426. else if (type === item[3]) {
  427. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_ROTATE;
  428. }
  429. else if (type === item[4]) {
  430. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_SCALE;
  431. }
  432. else if (type === item[5]) {
  433. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_SHOW;
  434. }
  435. else if (type === item[6]) {
  436. animationtype = SuperMap.Plot.GOAnimationType.ANIMATION_WAY;
  437. }
  438. var obj = new Object();
  439. obj.selectValue = type;
  440. obj.animationType = animationtype;
  441. return obj;
  442. }
  443. function execute() {
  444. goAnimationManager.execute();
  445. }
  446. function deleteSelectedFeaturesAnimation() {
  447. widgets.alert.clearAlert();
  448. if (null === goAnimationManager.goAnimations) {
  449. return;
  450. }
  451. if (0 === plottingLayer.selectedFeatures.length) {
  452. return;
  453. }
  454. var selectFeature = plottingLayer.selectedFeatures[0];
  455. var animations = [];
  456. for (var i = 0; i < goAnimationManager.goAnimations.length; i++) {
  457. var animation = goAnimationManager.goAnimations[i];
  458. if (animation.goFeature === selectFeature) {
  459. animations.push(animation);
  460. }
  461. }
  462. for (var i = 0; i < animations.length; i++) {
  463. goAnimationManager.removeGOAnimation(animations[i]);
  464. }
  465. }
  466. function deleteAllAnimation() {
  467. widgets.alert.clearAlert();
  468. if (null === goAnimationManager.goAnimations) {
  469. return;
  470. }
  471. goAnimationManager.reset();
  472. goAnimationManager.removeAllGOAnimation();
  473. }
  474. function clearFeatures() {
  475. plottingLayer.removeAllFeatures();
  476. }
  477. document.onmouseup = function (evt) {
  478. var evt = evt || window.event;
  479. if (evt.button === 2) {
  480. PlottingDrawCancel();
  481. return false;
  482. }
  483. evt.stopPropagation();
  484. };
  485. </script>
  486. </body>
  487. </html>