plot_dynamicPlot.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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_dynamicPlot"></title>
  9. <style type="text/css">
  10. body {
  11. margin: 0;
  12. overflow: hidden;
  13. background: #fff;
  14. width: 100%;
  15. height: 100%;
  16. position: absolute;
  17. top: 0;
  18. }
  19. #map {
  20. position: absolute;
  21. left: 250px;
  22. right: 0px;
  23. height: 100%;
  24. }
  25. #plottingMenu {
  26. position: absolute;
  27. top: 20%;
  28. z-index: 888;
  29. border-radius: 4px;
  30. padding-top: 2px;
  31. left: 265px;
  32. color: #000000;
  33. background-color: #fff;
  34. }
  35. #plottingPanel {
  36. float: left;
  37. background: #ffffff;
  38. width: 250px;
  39. height: 100%;
  40. border: 1px solid #3473b7;
  41. }
  42. </style>
  43. </head>
  44. <body>
  45. <div id="map"></div>
  46. <div id="plottingPanel">
  47. <div class="easyui-panel" style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;">
  48. <div class="easyui-tabs" style="width: 100%;height: 100%">
  49. <div id="plotPanel" data-i18n="[title]resources.text_drawPanel" style="overflow: hidden"></div>
  50. <div id="stylePanel" data-i18n="[title]resources.text_attributePanel"></div>
  51. </div>
  52. </div>
  53. </div>
  54. <div id="plottingMenu" class="sticklr">
  55. <li>
  56. <a class="glyphicon plotting-glyphicon-draw-deactivate notArrow"
  57. data-i18n="[title]resources.text_cancelDraw"
  58. onclick="cancelDraw()"></a>
  59. </li>
  60. <li>
  61. <a class="glyphicon plotting-glyphicon-draw-removeAll notArrow"
  62. data-i18n="[title]resources.text_input_value_clear"></a>
  63. <ul>
  64. <li><input type="button" data-i18n="[value]resources.btn_deleteMarker" onclick="deleteSymbol()"
  65. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  66. <li><input type="button" data-i18n="[value]resources.btn_clearLayers" onclick="clearLayer()"
  67. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  68. </ul>
  69. </li>
  70. <li>
  71. <a class="glyphicon glyphicon-pencil notArrow" data-i18n="[title]resources.text_editor"></a>
  72. <ul>
  73. <li><input type="button" data-i18n="[value]resources.btn_copy" onclick="copySymbol()"
  74. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  75. <li><input type="button" data-i18n="[value]resources.btn_cut" onclick="cutSymbol()"
  76. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  77. <li><input type="button" data-i18n="[value]resources.btn_paste" onclick="pasteSymbol()"
  78. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  79. </ul>
  80. </li>
  81. <li>
  82. <a class="glyphicon glyphicon-plus notArrow" data-i18n="[title]resources.text_addLayer" onclick="addPlottingLayer()"></a>
  83. </li>
  84. <li>
  85. <a class="glyphicon plotting-lyphicon-save-simulationMap" data-i18n="[title]resources.text_situationMapOperation"></a>
  86. <ul>
  87. <li><input type="button" data-i18n="[value]resources.btn_saveSimulationMap" onclick="saveSimulationMap()"
  88. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  89. <li><input type="button" data-i18n="[value]resources.btn_loadSimulationMap" onclick="loadSimulationMap()"
  90. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  91. </ul>
  92. </li>
  93. <li>
  94. <a class="glyphicon glyphicon-edit notArrow" data-i18n="[title]resources.text_editMarker"></a>
  95. <ul>
  96. <li><input type="button" data-i18n="[value]resources.btn_editRectangle" onclick="editCircusRetangle()"
  97. style="width:85px;height: 25px ;margin:0 auto;"/> </li>
  98. <li><input type="button" data-i18n="[value]resources.btn_editNode" onclick="editContorPoints()"
  99. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  100. <li><input type="button" data-i18n="[value]resources.btn_addNode" onclick="addControlPoints()"
  101. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  102. <li><input type="button" data-i18n="[value]resources.btn_deleteNode" onclick="removeControlPoints()"
  103. style="width: 70px;height: 25px ;margin:0 auto;"> </input></li>
  104. </ul>
  105. </li>
  106. <li>
  107. <a class="glyphicon glyphicon-lock notArrow" data-i18n="[title]resources.text_aboutMode"></a>
  108. <ul>
  109. <li><input type="button" data-i18n="[value]resources.btn_lockSwitch" onclick="setPlottingLayerIsLocked()"
  110. style="width:85px;height: 25px ;margin:0 auto;"/> </li>
  111. <li><input type="button" data-i18n="[value]resources.btn_editSwitch" onclick="setPlottingLayerIsEdit()"
  112. style="width:85px;height: 25px ;margin:0 auto;"/> </li>
  113. <li><input type="button" data-i18n="[value]resources.btn_selectSwitch" onclick="setPlottingLayerIsSelected()"
  114. style="width:85px;height: 25px ;margin:0 auto;"/> </li>
  115. </ul>
  116. </li>
  117. <li>
  118. <a class="glyphicon glyphicon-check notArrow" data-i18n="[title]resources.text_multiselect" onclick="multiSelectModel()"></a>
  119. </li>
  120. <li>
  121. <a class="glyphicon glyphicon-align-justify notArrow" data-i18n="[title]resources.text_multiselectAlign"></a>
  122. <ul>
  123. <li><input type="button" data-i18n="[value]resources.btn_leftAlignment" onclick="setSymbolAlighLeft()"
  124. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  125. <li><input type="button" data-i18n="[value]resources.btn_rightAlignment" onclick="setSymbolAlighRight()"
  126. style="width: 70px;height: 25px ;margin:0 auto;"/></li>
  127. <li><input type="button" data-i18n="[value]resources.btn_topAlignment" onclick="setSymbolAlighUp()"
  128. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  129. <li><input type="button" data-i18n="[value]resources.btn_bottomAlignment" onclick="setSymbolAlighDown()"
  130. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  131. <li><input type="button" data-i18n="[value]resources.btn_verticalCenter" onclick="setSymbolAlighVerticalcenter()"
  132. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  133. <li><input type="button" data-i18n="[value]resources.btn_horizontalCenter" onclick="setSymbolAlighHorizontalcenter()"
  134. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  135. </ul>
  136. </li>
  137. <li>
  138. <a class="glyphicon glyphicon-adjust notArrow" data-i18n="[title]resources.text_avoid"></a>
  139. <ul>
  140. <li><input type="button" data-i18n="[value]resources.btn_avoidEdit" onclick="drawAvoidRegion()"
  141. style="width:80px;height: 25px ;margin:0 auto;"/> </li>
  142. <li><input type="button" data-i18n="[value]resources.btn_cancelAvoidEdit" onclick="doneAvoidEdit()"
  143. style="width:80px;height: 25px ;margin:0 auto;"/> </li>
  144. <li><input type="button" data-i18n="[value]resources.btn_deleteAvoid" onclick="deleteAvoidEdit()"
  145. style="width:80px;height: 25px ;margin:0 auto;"/> </li>
  146. </ul>
  147. </li>
  148. <li>
  149. <a class="glyphicon glyphicon-gift notArrow" data-i18n="[title]resources.text_createGroup"></a>
  150. <ul>
  151. <li><input type="button" data-i18n="[value]resources.btn_group" onclick="createGroupObjects()"
  152. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  153. <li><input type="button" data-i18n="[value]resources.btn_flags" onclick="createDrawFlags()"
  154. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  155. <li><input type="button" data-i18n="[value]resources.btn_unbundling" onclick="unGroupObject()"
  156. style="width:70px;height: 25px ;margin:0 auto;"/> </li>
  157. </ul>
  158. </li>
  159. <li>
  160. <a class="glyphicon glyphicon-arrow-left notArrow" data-i18n="[title]resources.btn_undo" onclick="undo()"></a>
  161. </li>
  162. <li>
  163. <a class="glyphicon glyphicon-arrow-right notArrow" data-i18n="[title]resources.btn_redo" onclick="redo()"></a>
  164. </li>
  165. <li>
  166. <a class="glyphicon glyphicon-th-large notArrow" data-i18n="[title]resources.text_symbolEqualSize" ></a>
  167. <ul>
  168. <li><input type="button" data-i18n="[value]resources.btn_symbolEqualWidth" onclick="setSymbolEqualWidth()"
  169. style="width:70px;height: 25px ;margin:0 auto;"> </input> </li>
  170. <li><input type="button" data-i18n="[value]resources.btn_symbolEqualHeight" onclick="setSymbolEqualHeight()"
  171. style="width: 70px;height: 25px ;margin:0 auto;"> </input></li>
  172. <li><input type="button" data-i18n="[value]resources.btn_symbolEqualWidthHeight" onclick="setSymbolEqualWidthHeight()"
  173. style="width:70px;height: 25px ;margin:0 auto;"> </input> </li>
  174. </ul>
  175. </li>
  176. <li>
  177. <a class="glyphicon glyphicon-th" data-i18n="[title]resources.text_symbolDistribution" ></a>
  178. <ul>
  179. <li><input type="button" data-i18n="[value]resources.btn_symbolLevelDistribution" onclick="setSymbolLevelDistribution()"
  180. style="width:70px;height: 25px ;margin:0 auto;"> </input> </li>
  181. <li><input type="button" data-i18n="[value]resources.btn_symbolVerticalDistribution" onclick="setSymbolVerticalDistribution()"
  182. style="width: 70px;height: 25px ;margin:0 auto;"> </input></li>
  183. </ul>
  184. </li>
  185. </div>
  186. <div id="contentMe" style="width:100px;background-color:#f4f4f4;box-shadow:3px 3px 3px rgba(0,0,0,0.5);position:absolute;z-index:1000; top:20px;left:100px;display:none;text-align:center;">
  187. <a href="javascript:void(0)" id="paste" style="border-bottom:1px solid #ccc;display:block;line-height:20px;color:#000; font-size:16px;">粘贴此处</a>
  188. </div>
  189. <script type="text/javascript" include="bootstrap,responsive,sticklr,plottingPanel" src="../js/include-web.js"></script>
  190. <script type="text/javascript" include="iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
  191. <script type="text/javascript" include="PlotPanel,StylePanel" src="../js/plottingPanel/PlottingPanel.Include.js"></script>
  192. <script type="text/javascript">
  193. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  194. var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
  195. var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
  196. var map;
  197. map = L.map('map', {
  198. preferCanvas: true,
  199. crs: L.CRS.EPSG4326,
  200. center: [35, 104],
  201. maxZoom: 18,
  202. zoom: 3
  203. });
  204. L.supermap.tiledMapLayer(url).addTo(map);
  205. var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
  206. plottingLayer.addTo(map);
  207. var drawControl = L.supermap.plotting.drawControl(plottingLayer);
  208. drawControl.addTo(map);
  209. var editControl = L.supermap.plotting.editControl();
  210. editControl.addTo(map);
  211. L.supermap.plotting.initPlotPanel("plotPanel", serverUrl, drawControl);
  212. L.supermap.plotting.initStylePanel("stylePanel", serverUrl, editControl);
  213. var plotting = L.supermap.plotting.getControl(map, serverUrl);
  214. map.on('contextmenu', function (event) {
  215. drawControl.handler.disable();
  216. if(editControl.canPaste()){
  217. var contentMe = document.getElementById("contentMe");
  218. contentMe.style.top = event.originalEvent.clientY + "px";
  219. contentMe.style.left = event.originalEvent.clientX + "px";
  220. contentMe.style.display = "block";
  221. document.getElementById("paste").onclick = function(){
  222. editControl.paste(event.latlng);
  223. };
  224. }
  225. }).on('mousemove', function (event) {
  226. contentMe.style.display = "none";
  227. });
  228. //取消标绘
  229. function cancelDraw() {
  230. drawControl.handler.disable();
  231. }
  232. //清空绘制
  233. function clearLayer() {
  234. cancelDraw();
  235. for(var i = 0; i < map.getPlottingLayers().length; i++){
  236. map.getPlottingLayers()[i].removeAllFeatures();
  237. }
  238. }
  239. //删除选中标号
  240. function deleteSymbol() {
  241. editControl.deleteSelectedFeatures();
  242. }
  243. //复制
  244. function copySymbol() {
  245. editControl.copy();
  246. }
  247. //剪切
  248. function cutSymbol() {
  249. editControl.cut();
  250. }
  251. //粘贴
  252. function pasteSymbol() {
  253. editControl.paste();
  254. }
  255. //添加图层
  256. function addPlottingLayer() {
  257. cancelDraw();
  258. var plottingLayerName = "plottingLayer_" + Math.ceil(Math.random() * 1000);
  259. var plottingLayerNew = L.supermap.plotting.plottingLayer(plottingLayerName, serverUrl);
  260. drawControl.setDrawingLayer(plottingLayerNew);
  261. plottingLayerNew.addTo(map);
  262. alert("标绘图层"+plottingLayerNew.name+"增加成功!");
  263. }
  264. //保存态势图
  265. function saveSimulationMap() {
  266. cancelDraw();
  267. plotting.getSitDataManager().saveAsSmlFile("situationMap");
  268. }
  269. function loadSimulationMap() {
  270. plotting.getSitDataManager().openSmlFileOnServer("situationMap", function(evt){
  271. drawControl.setDrawingLayer(evt.sitDataLayers[0]);
  272. plottingLayer = evt.sitDataLayers[0];
  273. });
  274. }
  275. function editCircusRetangle() {
  276. editControl.setEditMode(SuperMap.Plot.EditMode.EDITCIRCUMRECTANGLE);
  277. }
  278. function editContorPoints() {
  279. editControl.setEditMode(SuperMap.Plot.EditMode.EDITCONTROLPOINT);
  280. }
  281. function addControlPoints() {
  282. editControl.setEditMode(SuperMap.Plot.EditMode.ADDCONTROLPOINT);
  283. }
  284. function removeControlPoints(){
  285. editControl.setEditMode(SuperMap.Plot.EditMode.REMOVECONTROLPOINT);
  286. }
  287. //切换多选模式
  288. function multiSelectModel() {
  289. editControl.multiSelect();
  290. }
  291. //多选对齐--左对齐
  292. function setSymbolAlighLeft() {
  293. editControl.align(SuperMap.Plot.AlignType.LEFT);
  294. }
  295. //多选对齐--右对齐
  296. function setSymbolAlighRight() {
  297. editControl.align(SuperMap.Plot.AlignType.RIGHT);
  298. }
  299. //多选对齐--上对齐
  300. function setSymbolAlighUp() {
  301. editControl.align(SuperMap.Plot.AlignType.UP);
  302. }
  303. //多选对齐--下对齐
  304. function setSymbolAlighDown() {
  305. editControl.align(SuperMap.Plot.AlignType.DOWN);
  306. }
  307. //多选对齐--竖直居中对齐
  308. function setSymbolAlighVerticalcenter() {
  309. editControl.align(SuperMap.Plot.AlignType.VERTICALCENTER);
  310. }
  311. //多选对齐--水平居中对齐
  312. function setSymbolAlighHorizontalcenter() {
  313. editControl.align(SuperMap.Plot.AlignType.HORIZONTALCENTER);
  314. }
  315. //切换图层是否锁定
  316. function setPlottingLayerIsLocked() {
  317. if (plottingLayer.getLocked() === true) {
  318. plottingLayer.setLocked(false);
  319. } else {
  320. plottingLayer.setLocked(true);
  321. }
  322. }
  323. //切换图层是否可编辑模式
  324. function setPlottingLayerIsEdit() {
  325. if (plottingLayer.getEditable() === true) {
  326. plottingLayer.setEditable(false);
  327. } else {
  328. plottingLayer.setEditable(true);
  329. }
  330. }
  331. //切换图层是否可选择模式
  332. function setPlottingLayerIsSelected() {
  333. if (plottingLayer.getSelected() === true) {
  334. plottingLayer.setSelected(false);
  335. } else {
  336. plottingLayer.setSelected(true);
  337. }
  338. }
  339. function drawAvoidRegion(){
  340. if (editControl._avoidEditing === false && editControl.getSelectedFeatures().length === 0) {
  341. return;
  342. }else{
  343. editControl.avoidEdit(true);
  344. }
  345. }
  346. function doneAvoidEdit(){
  347. editControl.avoidEdit(false);
  348. }
  349. function deleteAvoidEdit(){
  350. if (editControl._avoidEditing === false && editControl.getSelectedFeatures().length === 0) {
  351. return ;
  352. }else if(editControl._avoidEditing === true){
  353. editControl.avoidEdit(false);
  354. editControl.getSelectedFeatures()[0].removeAvoidRegions();
  355. }
  356. }
  357. //创建组合对象
  358. function createGroupObjects() {
  359. var features = editControl.getSelectedFeatures();
  360. if (features.length >= 2) {
  361. var groupObject = plottingLayer.createGroupObject(features);
  362. if(!!groupObject){
  363. editControl.selectFeatures(groupObject);
  364. }
  365. var feature = plottingLayer.features[plottingLayer.features.length-1];
  366. var transaction = new SuperMap.Plot.Transaction();
  367. transaction.transType = SuperMap.Plot.TransactionType.EDIT;
  368. var transInfo = new SuperMap.Plot.TransactionInfo();
  369. transInfo.layerId = plottingLayer._leaflet_id;
  370. transInfo.uuid = feature.uuid;
  371. transInfo.functionName = "createGroupObject";
  372. transInfo.undoParams = [feature];
  373. transInfo.redoParams = [features];
  374. transaction.transInfos.push(transInfo);
  375. L.supermap.plotting.getControl().getTransManager().add(transaction);
  376. }
  377. }
  378. //创建多旗
  379. function createDrawFlags() {
  380. var features = editControl.getSelectedFeatures();
  381. if (features.length >= 2) {
  382. var flagObject = plottingLayer.createFlags(features);
  383. if(!!flagObject){
  384. editControl.selectFeatures(flagObject);
  385. }
  386. var transaction = new SuperMap.Plot.Transaction();
  387. transaction.transType = SuperMap.Plot.TransactionType.EDIT;
  388. var transInfo = new SuperMap.Plot.TransactionInfo();
  389. transInfo.layerId = flagObject.layer._leaflet_id;
  390. transInfo.uuid = flagObject.uuid;
  391. transInfo.functionName = "createFlags";
  392. transInfo.undoParams = [flagObject];
  393. transInfo.redoParams = [features];
  394. transaction.transInfos.push(transInfo);
  395. L.supermap.plotting.getControl().getTransManager().add(transaction);
  396. }
  397. }
  398. //解绑组合对象
  399. function unGroupObject() {
  400. var features = editControl.getSelectedFeatures();
  401. for (var i = features.length - 1; i >= 0; i--) {
  402. if (features[i] instanceof L.supermap.plotting.GroupObject) {
  403. var subLayers = plottingLayer.unGroupObject(features[i]);
  404. editControl.selectFeatures(subLayers);
  405. }
  406. }
  407. }
  408. function undo(){
  409. editControl.avoidEdit(false);
  410. plotting.getTransManager().undo();
  411. editControl.fire(SuperMap.Plot.Event.featuresmodified);//刷新属性面板
  412. }
  413. function redo(){
  414. editControl.avoidEdit(false);
  415. plotting.getTransManager().redo();
  416. editControl.fire(SuperMap.Plot.Event.featuresmodified);//刷新属性面板
  417. }
  418. //等大
  419. //等宽
  420. function setSymbolEqualWidth(){
  421. editControl.equalLarge(SuperMap.Plot.EqualLargeType.WIDTH);
  422. }
  423. //等高
  424. function setSymbolEqualHeight(){
  425. editControl.equalLarge(SuperMap.Plot.EqualLargeType.HEIGHT);
  426. }
  427. //等宽高
  428. function setSymbolEqualWidthHeight(){
  429. editControl.equalLarge(SuperMap.Plot.EqualLargeType.SAME);
  430. }
  431. //均匀分布
  432. //横向均匀分布
  433. function setSymbolLevelDistribution(){
  434. editControl.uniformDistribution(SuperMap.Plot.UniformDistributionType.LEVEL);
  435. }
  436. //纵向均匀分布
  437. function setSymbolVerticalDistribution(){
  438. editControl.uniformDistribution(SuperMap.Plot.UniformDistributionType.VERTICAL);
  439. }
  440. document.onkeydown = function (event) {
  441. var event = event || window.event;
  442. if(event && event.keyCode === 46){//Delete键
  443. editControl.deleteSelectedFeatures();
  444. }
  445. }
  446. // document.oncontextmenu = function (event) {
  447. // var event = event || window.event;
  448. // if(event.button == 2){
  449. // drawControl.handler.disable();
  450. // }
  451. // }
  452. </script>
  453. </body>
  454. </html>