plot_symbolAvoid.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_symbolAvoid"></title>
  9. </head>
  10. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  11. <div id="toolbar" class="panel panel-primary" style=" position: absolute;top: 10px;right: 10px;text-align: center;z-index: 9999;border-radius: 4px;">
  12. <div class='panel-heading' id="panelheading">
  13. <h5 class='panel-title text-center' data-i18n="resources.title_symbolAvoid"></h5></div>
  14. <div class='panel-body content' id="panelbodycontent">
  15. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_avoidEdit" onclick="drawAvoidRegion()"/>
  16. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_cancelAvoidEdit" onclick="doneAvoidEdit()"/>
  17. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_deleteAvoid" onclick="deleteAvoidEdit()"/>
  18. </div>
  19. </div>
  20. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  21. <script type="text/javascript" include="bootstrap,widgets.alert,jquery" src="../js/include-web.js"></script>
  22. <script type="text/javascript" include="iclient-leaflet-css,iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
  23. <script type="text/javascript">
  24. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  25. var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
  26. var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
  27. var map,symbolLibManager;
  28. map = L.map('map', {
  29. preferCanvas: true,
  30. crs: L.CRS.EPSG4326,
  31. center: [34.91, 114.8225],
  32. zoom: 5,
  33. maxZoom: 18
  34. });
  35. L.supermap.tiledMapLayer(url).addTo(map);
  36. var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
  37. plottingLayer.addTo(map);
  38. var drawControl = L.supermap.plotting.drawControl(plottingLayer);
  39. drawControl.addTo(map);
  40. var editControl = L.supermap.plotting.editControl();
  41. editControl.addTo(map);
  42. var plotting = L.supermap.plotting.getControl(map, serverUrl);
  43. function loadSymbolLib() {
  44. symbolLibManager = plotting.getSymbolLibManager();
  45. symbolLibManager.libIDs = [421];
  46. symbolLibManager.on( SuperMap.Plot.Event.initializecompleted,initializeCompleted);
  47. symbolLibManager.initializeAsync();
  48. }
  49. function initializeCompleted() {
  50. plotSymbol();
  51. }
  52. function plotSymbol(){
  53. var symbolLib = symbolLibManager.getSymbolLibByIndex(0);
  54. var libID = symbolLib.libID;
  55. var latlngs = [];
  56. latlngs.push(new L.latLng(35.7875,107.02625));
  57. latlngs.push(new L.latLng(33.65,112.67375));
  58. latlngs.push(new L.latLng(36.575,114.81125));
  59. plottingLayer.createSymbol(0, 390, latlngs);
  60. plottingLayer.createSymbol(libID, 9, [new L.latLng(35.2925,107.02625)]);
  61. plottingLayer.createSymbol(libID, 80102, [new L.latLng(36.08,110.78375)]);
  62. plottingLayer.createSymbol(libID, 80105, [new L.latLng(35.8775,114.87875)]);
  63. }
  64. function drawAvoidRegion(){
  65. widgets.alert.clearAlert();
  66. if (editControl._avoidEditing === false && editControl.getSelectedFeatures().length === 0) {
  67. widgets.alert.showAlert("避让编辑之前请先选择标号!",true);
  68. }else{
  69. editControl.avoidEdit(true);
  70. }
  71. }
  72. function doneAvoidEdit(){
  73. widgets.alert.clearAlert();
  74. editControl.avoidEdit(false);
  75. }
  76. function deleteAvoidEdit(){
  77. widgets.alert.clearAlert();
  78. if (editControl._avoidEditing === false && editControl.getSelectedFeatures().length === 0) {
  79. widgets.alert.showAlert("删除避让区域之前请先请先选择标号!",true);
  80. }else if(editControl._avoidEditing === true){
  81. editControl.avoidEdit(false);
  82. editControl.getSelectedFeatures()[0].removeAvoidRegions();
  83. widgets.alert.showAlert("删除避让区域成功!",true);
  84. }
  85. }
  86. function PlottingDrawCancel(){
  87. drawControl.handler.disable();
  88. }
  89. window.onload = function(){
  90. loadSymbolLib();
  91. };
  92. $(document).ready(function(){
  93. $('#panelheading').click(function(){
  94. $('#panelbodycontent').toggle();
  95. });
  96. });
  97. </script>
  98. </body>
  99. </html>