plot_symbolEditor.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.text_editor"></title>
  9. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  10. <div id="toolbar" class="panel panel-primary" style=" position: absolute;top: 10px;right: 10px;text-align: center;z-index: 9999;border-radius: 4px;">
  11. <div class='panel-heading' id="panelheading">
  12. <h5 class='panel-title text-center' data-i18n="resources.text_editor"></h5></div>
  13. <div class='panel-body content' id="panelbodycontent">
  14. <input id="btn_Copy" type="button" class="btn btn-default" data-i18n="[value]resources.btn_copy" onclick="copySymbol()" />
  15. <input id="btn_Cut" type="button" class="btn btn-default" data-i18n="[value]resources.btn_cut" onclick="cutSymbol()" />
  16. <input id="btn_Paste" type="button" class="btn btn-default" data-i18n="[value]resources.btn_paste" onclick="pasteSymbol()" />
  17. <input id="btn_Reset" type="button" class="btn btn-default" data-i18n="[value]resources.btn_reset" onclick="resetSymbol()" />
  18. </div>
  19. </div>
  20. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  21. <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;">
  22. <a href="javascript:void(0)" id="paste" style="border-bottom:1px solid #ccc;display:block;line-height:20px;color:#000; font-size:16px;">粘贴此处</a>
  23. </div>
  24. <script type="text/javascript" include="bootstrap-css" src="../js/include-web.js"></script>
  25. <script type="text/javascript" include="iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
  26. <script type="text/javascript">
  27. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  28. var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
  29. var serverUrl = host+"/iserver/services/plot-jingyong/rest/plot/";
  30. var map;
  31. map = L.map('map', {
  32. preferCanvas: true,
  33. crs: L.CRS.EPSG4326,
  34. center: [35,104],
  35. maxZoom: 18,
  36. zoom: 3
  37. });
  38. L.supermap.tiledMapLayer(url).addTo(map);
  39. var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
  40. plottingLayer.addTo(map);
  41. var drawControl = L.supermap.plotting.drawControl(plottingLayer);
  42. drawControl.addTo(map);
  43. var editControl = L.supermap.plotting.editControl();
  44. editControl.addTo(map);
  45. var plotting = L.supermap.plotting.getControl(map, serverUrl);
  46. function plotSymbol() {
  47. //标绘多边形
  48. var polygonPoints = [];
  49. polygonPoints.push(new L.latLng(41,89));
  50. polygonPoints.push(new L.latLng(33,85));
  51. polygonPoints.push(new L.latLng(29,93));
  52. polygonPoints.push(new L.latLng(34,101));
  53. polygonPoints.push(new L.latLng(41,99));
  54. plottingLayer.createSymbol(0, SuperMap.Plot.SymbolType.ARBITRARYPOLYGONSYMBOL, polygonPoints);
  55. //标绘折线
  56. var linePoints = [];
  57. linePoints.push(new L.latLng(29, 107));
  58. linePoints.push(new L.latLng(36,110));
  59. linePoints.push(new L.latLng(28,113));
  60. linePoints.push(new L.latLng(37,118));
  61. plottingLayer.createSymbol(0, SuperMap.Plot.SymbolType.POLYLINESYMBOL, linePoints);
  62. }
  63. function copySymbol() {
  64. editControl.copy();
  65. }
  66. function cutSymbol() {
  67. editControl.cut();
  68. }
  69. function pasteSymbol() {
  70. editControl.paste();
  71. }
  72. function resetSymbol() {
  73. plottingLayer.removeAllFeatures();
  74. plotSymbol();
  75. }
  76. map.on('contextmenu', function (event) {
  77. if(editControl.getSelectedFeatures().length == 0){
  78. return;
  79. }
  80. var contentMe = document.getElementById("contentMe");
  81. contentMe.style.top = event.originalEvent.clientY + "px";
  82. contentMe.style.left = event.originalEvent.clientX + "px";
  83. contentMe.style.display = "block";
  84. document.getElementById("paste").onclick = function(){
  85. editControl.paste(event.latlng);
  86. };
  87. }).on('mousemove', function (event) {
  88. contentMe.style.display = "none";
  89. })
  90. window.onload = function(){
  91. plotSymbol();
  92. };
  93. $(document).ready(function(){
  94. $('#panelheading').click(function(){
  95. $('#panelbodycontent').toggle();
  96. });
  97. });
  98. </script>
  99. </body>
  100. </html>