plot_symbolExtendProperty.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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_symbolExtendProperty"></title>
  9. </head>
  10. <body style=" overflow: hidden;width: 100%;height:100%;position: absolute;top: 0;">
  11. <div id="toolbar" class="panel panel-primary" style="position: absolute;top: 15px;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_symbolExtendProperty"></h5>
  14. </div>
  15. <div class='panel-body content' id="panelbodycontent">
  16. <div class='panel'>
  17. <div class='input-group' style="margin-bottom: 15px;width: 185px;">
  18. <span class='input-group-addon' data-i18n="resources.text_propertyName"></span>
  19. <input class='form-control' id='propertyName' value=''/>
  20. </div>
  21. <div class='input-group' style="margin-bottom: 15px;width: 185px;">
  22. <span class='input-group-addon' data-i18n="resources.text_propertyValue"></span>
  23. <input class='form-control' id='propertyValue' value=''/>
  24. </div>
  25. </div>
  26. <input id="btn" type="button" class="btn btn-default" data-i18n="[value]resources.btn_addProperty" onclick="addExtendProperty()"/>
  27. </div>
  28. </div>
  29. <div id="popupWin" class="panel panel-primary popupWindow" style=" position: absolute;right: 10px;top: 247px;width: 220px;background: #FFF;z-index: 9999;display: block;">
  30. <div class="winTitle" style=" background: #1E90FF;">
  31. <span class="title_left" data-i18n="resources.title_symbolExtendProperty"></span>
  32. </div>
  33. <div id="extendProperty" class="winContent" style=" padding: 5px;overflow-y: auto;height: 300px;"></div>
  34. </div>
  35. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  36. <script type="text/javascript" include="bootstrap,widgets.alert,jquery" src="../js/include-web.js"></script>
  37. <script type="text/javascript" include="iclient-leaflet-css,iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
  38. <script type="text/javascript">
  39. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  40. var url = host + "/iserver/services/map-china400/rest/maps/China_4326";
  41. var serverUrl = host + "/iserver/services/plot-jingyong/rest/plot/";
  42. var map;
  43. map = L.map('map', {
  44. preferCanvas: true,
  45. crs: L.CRS.EPSG4326,
  46. center: [0, 0],
  47. zoom: 2,
  48. maxZoom: 18
  49. });
  50. L.supermap.tiledMapLayer(url).addTo(map);
  51. var plottingLayer = L.supermap.plotting.plottingLayer("plot", serverUrl);
  52. plottingLayer.addTo(map);
  53. var drawControl = L.supermap.plotting.drawControl(plottingLayer);
  54. drawControl.addTo(map);
  55. var editControl = L.supermap.plotting.editControl();
  56. editControl.addTo(map);
  57. var plotting = L.supermap.plotting.getControl(map, serverUrl);
  58. function plotSymbol(){
  59. //标绘多边形
  60. var polygonPoints = [];
  61. polygonPoints.push(L.latLng(0,-20));
  62. polygonPoints.push(L.latLng(20,-10));
  63. polygonPoints.push(L.latLng(40,-30));
  64. polygonPoints.push(L.latLng(10,-60));
  65. plottingLayer.createSymbol(0, SuperMap.Plot.SymbolType.ARBITRARYPOLYGONSYMBOL, polygonPoints);
  66. //标绘折线
  67. var linePoints = [];
  68. linePoints.push(L.latLng(0, 0));
  69. linePoints.push(L.latLng(20, 0));
  70. linePoints.push(L.latLng(10,20));
  71. linePoints.push(L.latLng(30,10));
  72. plottingLayer.createSymbol(0, SuperMap.Plot.SymbolType.POLYLINESYMBOL, linePoints);
  73. //标绘点
  74. var dotPoints = [];
  75. dotPoints.push(L.latLng(8.3515625,-75.96875));
  76. plottingLayer.createSymbol(421, 9, dotPoints,{symbolType:SuperMap.Plot.SymbolType.DOTSYMBOL});
  77. }
  78. editControl.on(SuperMap.Plot.Event.featuresselected, function(event){
  79. showExtendProperty(event);
  80. });
  81. editControl.on(SuperMap.Plot.Event.featuresunselected, function(event){
  82. showExtendProperty(event);
  83. });
  84. function addExtendProperty() {
  85. widgets.alert.clearAlert();
  86. var key = document.getElementById("propertyName").value;
  87. var value = document.getElementById("propertyValue").value;
  88. if ("" === key || "" === value) {
  89. return;
  90. }
  91. var layers = editControl.getSelectedFeatures();
  92. if (0 === layers.length) {
  93. widgets.alert.showAlert("请选择您要编辑的标号!",true);
  94. return;
  95. }
  96. var extendProperty = layers[0].getExtendProperty();
  97. extendProperty.addProperty(key, value);
  98. showExtendProperty();
  99. }
  100. function showExtendProperty() {
  101. document.all.extendProperty.innerHTML = "";
  102. //获取选中的对象
  103. var layers = editControl.getSelectedFeatures();
  104. if (0 === layers.length) {
  105. return;
  106. }
  107. var extendProperty = layers[0].getExtendProperty();
  108. var nPropertyCount = extendProperty.getPropertyCount();
  109. if (0 === nPropertyCount) {
  110. return;
  111. }
  112. var container = document.getElementById("extendProperty");
  113. var table = document.createElement("table");
  114. var body = document.createElement("tbody");
  115. table.setAttribute("border", "1");
  116. table.setAttribute("borderColor", "black");
  117. table.setAttribute("width", "100%");
  118. var tr = document.createElement("tr");
  119. //添加属性名
  120. var td_Name = document.createElement("th");
  121. var text_Name = document.createTextNode("属性名");
  122. td_Name.appendChild(text_Name);
  123. tr.appendChild(td_Name);
  124. //添加属性值
  125. var td_Value = document.createElement("th");
  126. var text_Value = document.createTextNode("属性值");
  127. td_Value.appendChild(text_Value);
  128. tr.appendChild(td_Value);
  129. body.appendChild(tr);
  130. for (var i = 0; i < nPropertyCount; i++) {
  131. var property = extendProperty.getPropertyByIndex(i);
  132. if (null === property) {
  133. continue;
  134. }
  135. var _tr = document.createElement("tr");
  136. //添加属性名
  137. var td_PropertyName = document.createElement("td");
  138. var text_propertyName = document.createTextNode(property.getKey());
  139. td_PropertyName.appendChild(text_propertyName);
  140. _tr.appendChild(td_PropertyName);
  141. //添加属性值
  142. var td_PropertyValue = document.createElement("td");
  143. var text_propertyValue = document.createTextNode(property.getValue());
  144. td_PropertyValue.appendChild(text_propertyValue);
  145. _tr.appendChild(td_PropertyValue);
  146. body.appendChild(_tr);
  147. }
  148. table.appendChild(body);
  149. container.appendChild(table);
  150. }
  151. window.onload = function(){
  152. plotSymbol();
  153. };
  154. $(document).ready(function(){
  155. $('#panelheading').click(function(){
  156. $('#panelbodycontent').toggle();
  157. $('#popupWin').toggle();
  158. });
  159. });
  160. </script>
  161. </body>
  162. </html>