overlay_graphicSymbolData.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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_graphicSymbolData"></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. width: 100%;
  20. height: 100%;
  21. border: 1px solid #3473b7;
  22. }
  23. #toolbar {
  24. position: absolute;
  25. top: 50px;
  26. right: 10px;
  27. width: 300px;
  28. text-align: center;
  29. z-index: 100;
  30. border-radius: 4px;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <div id="toolbar" class="panel panel-primary">
  36. <div class='panel-heading'>
  37. <h5 class='panel-title text-center' data-i18n="resources.text_graphicSymbolData"></h5>
  38. </div>
  39. <div class='panel-body content'>
  40. <div class='panel'>
  41. <div class='input-group'>
  42. <span class='input-group-addon'><span data-i18n="resources.text_countsDraw"></span><span
  43. data-i18n="[title]resources.text_requiredField" style='color: red;'> * </span></span>
  44. <input id='total' type='text' class='form-control' value='1000'/>
  45. </div>
  46. </div>
  47. <div class='input-group'>
  48. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_startDraw"
  49. onclick="addData()"/>&nbsp;&nbsp;
  50. <input type="button" class="btn btn-default" data-i18n="[value]resources.text_remove"
  51. onclick="removeData()"/>
  52. </div>
  53. </div>
  54. </div>
  55. <div id="map"></div>
  56. <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
  57. <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
  58. <script>
  59. var map, layer, graphicLayer,
  60. host = window.isLocal ? window.server : "https://iserver.supermap.io",
  61. url = host + "/iserver/services/map-china400/rest/maps/China";
  62. init();
  63. function init() {
  64. if (!document.createElement("canvas").getContext) {
  65. widgets.alert.showAlert(resources.msg_supportCanvas, false);
  66. return;
  67. }
  68. map = new SuperMap.Map("map", {
  69. controls: [
  70. new SuperMap.Control.Zoom(),
  71. new SuperMap.Control.Navigation(),
  72. ]
  73. });
  74. map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
  75. layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null, {maxResolution: "auto"});
  76. layer.events.on({"layerInitialized": addLayer});
  77. graphicLayer = new SuperMap.Layer.Graphics("Graphic Layer");
  78. }
  79. function addLayer() {
  80. map.addLayers([layer, graphicLayer]);
  81. //显示地图范围
  82. map.setCenter(new SuperMap.LonLat(0, 0), 3);
  83. }
  84. //symbol相关属性 填充色、边框颜色、半径、
  85. var fillColors = ['rgba(255,153,0,0.4)', 'rgba(70,80,224,0.4)', 'rgba(60,150,79,0.4)', 'rgba(176,61,35,0.4)'];
  86. var strokeColors = ['rgba(255,204,0,0.2)', 'rgba(12,21,138,0.2)', 'rgba(20,99,32,0.2)', 'rgba(145,43,20,0.2)'];
  87. var radius = [3, 6, 9, 12, 15, 18];
  88. var sybolCount = fillColors.length * radius.length * 2;
  89. var symbols = [];
  90. for (var i = 0; i < fillColors.length; i++) {
  91. for (var j = 0; j < radius.length; j++) {
  92. //circle symbol
  93. symbols.push(new SuperMap.Style.Circle({
  94. radius: radius[j],
  95. fill: new SuperMap.Style.Fill({
  96. color: fillColors[i]
  97. }),
  98. stroke: new SuperMap.Style.Stroke({
  99. color: strokeColors[i]
  100. })
  101. }));
  102. //star symbol
  103. symbols.push(new SuperMap.Style.RegularShape({
  104. pointsLength: 5,
  105. radius: radius[j],
  106. radius1: radius[j] * 0.6,
  107. fill: new SuperMap.Style.Fill({
  108. color: fillColors[i]
  109. }),
  110. stroke: new SuperMap.Style.Stroke({
  111. color: strokeColors[i]
  112. })
  113. }));
  114. }
  115. }
  116. var total, t1, t2;
  117. var e = 10000000;
  118. function addData() {
  119. widgets.alert.clearAlert();
  120. graphicLayer.removeAllGraphics();
  121. var total = document.getElementById("total").value;
  122. t1 = new Date().getTime();
  123. var points = [];
  124. for (var i = 0; i < total; i++) {
  125. var point = new SuperMap.Geometry.Point(2 * e * Math.random() - e, 2 * e * Math.random() - e);
  126. var pointVector = new SuperMap.Graphic(point);
  127. pointVector.style = {
  128. image: symbols[i % sybolCount]
  129. };
  130. points.push(pointVector)
  131. }
  132. graphicLayer.addGraphics(points);
  133. //消耗时间计算
  134. t2 = new Date().getTime();
  135. //console.info(total + "个总时间为:" + (t2-t1) + "ms");
  136. widgets.alert.showAlert(resources.msg_totalTime1 + total + resources.msg_totalTime2 + total + (t2 - t1) + "ms", true);
  137. }
  138. //移除数据
  139. function removeData() {
  140. widgets.alert.clearAlert();
  141. graphicLayer.removeAllGraphics();
  142. graphicLayer.refresh();
  143. }
  144. </script>
  145. </body>
  146. </html>