deckglLayer_sftrees.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  9. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  10. <title data-i18n="resources.title_mb_deckglLayer_sftrees"></title>
  11. <style>
  12. body {
  13. margin: 0;
  14. overflow: hidden;
  15. background: #fff;
  16. width: 100%;
  17. height: 100%
  18. }
  19. #map {
  20. position: absolute;
  21. top: 0;
  22. bottom: 0;
  23. width: 100%;
  24. }
  25. #title {
  26. position: absolute;
  27. color: white;
  28. left: 40%;
  29. top: 30px;
  30. text-align: center;
  31. width: 500px;
  32. z-index: 2;
  33. }
  34. #title > h3 {
  35. margin: 10px 0;
  36. letter-spacing: 0.1em;
  37. }
  38. #title > h6 {
  39. margin: 0;
  40. font-weight: normal;
  41. }
  42. .whiteBackground {
  43. background-color: rgba(225, 225, 225, 0.1);
  44. border-top: 1px dotted;
  45. border-image: linear-gradient(to right, rgba(114, 159, 207, 1), rgba(104, 104, 104, 1) 200px, rgba(104, 104, 104, 0) 75%) 30;
  46. }
  47. .legendContainer {
  48. position: absolute;
  49. bottom: 25px;
  50. right: 25px;
  51. color: white;
  52. padding: 10px 10px 0px 10px;
  53. z-index: 1000;
  54. }
  55. .legendHead {
  56. align-self: flex-end;
  57. }
  58. .legendBody {
  59. padding-top: 10px;
  60. }
  61. </style>
  62. </head>
  63. <body>
  64. <div id="title">
  65. <h3 data-i18n="resources.title_mb_deckglLayer_sftrees"></h3>
  66. <h6 data-i18n="resources.text_mb_deckglLayer_sftrees"></h6>
  67. </div>
  68. <div class="legendContainer whiteBackground">
  69. <div class="legendHead _flex">
  70. <div>Point</div>
  71. <div>Hexbin color</div>
  72. <div>by Point Count</div>
  73. </div>
  74. <div class="legendBody _flex">
  75. <svg width="120" height="200">
  76. <g transform="translate(0, 0)">
  77. <rect width="30" height="20" style="fill: rgb(43, 30, 61);"></rect>
  78. <text x="38" y="14" fill="white">[ 1.0, 5.1 ]</text>
  79. </g>
  80. <g transform="translate(0, 24)">
  81. <rect width="30" height="20" style="fill: rgb(56, 60, 101);"></rect>
  82. <text x="38" y="14" fill="white">( 5.1, 9.3 ]</text>
  83. </g>
  84. <g transform="translate(0, 48)">
  85. <rect width="30" height="20" style="fill: rgb(62, 95, 126);"></rect>
  86. <text x="38" y="14" fill="white">( 9.3, 13.4 ]</text>
  87. </g>
  88. <g transform="translate(0, 72)">
  89. <rect width="30" height="20" style="fill: rgb(73, 131, 138);"></rect>
  90. <text x="38" y="14" fill="white">( 13.4 , 17.6 ]</text>
  91. </g>
  92. <g transform="translate(0, 96)">
  93. <rect width="30" height="20" style="fill: rgb(94, 162, 141);"></rect>
  94. <text x="38" y="14" fill="white">( 17.6, 21.6 ]</text>
  95. </g>
  96. <g transform="translate(0, 120)">
  97. <rect width="30" height="20" style="fill: rgb(130, 187, 146);"></rect>
  98. <text x="38" y="14" fill="white">( 21.6, 25.8 ]</text>
  99. </g>
  100. <g transform="translate(0, 144)">
  101. <rect width="30" height="20" style="fill: rgb(174, 206, 161);"></rect>
  102. <text x="38" y="14" fill="white">( 25.8, 29.9 ]</text>
  103. </g>
  104. <g transform="translate(0, 168)">
  105. <rect width="30" height="20" style="fill: rgb(214, 222, 191);"></rect>
  106. <text x="38" y="14" fill="white">( 29.9, 34.0 ]</text>
  107. </g>
  108. </svg>
  109. </div>
  110. </div>
  111. <div id="map"></div>
  112. <script type="text/javascript" include="papaparse,bootstrap,widgets" src="../js/include-web.js"></script>
  113. <script type="text/javascript" include="deck" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  114. <script type="text/javascript">
  115. var host = window.isLocal ? window.server : "https://iserver.supermap.io",
  116. url = host + "/iserver/services/map-china400/rest/maps/ChinaDark";
  117. var map, popup;
  118. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  119. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  120. " Map Data <span>© <a href='https://uber.github.io/kepler.gl' target='_blank'>kepler.gl</a></span> ";
  121. map = new mapboxgl.Map({
  122. container: 'map',
  123. style: {
  124. "version": 8,
  125. "sources": {
  126. "raster-tiles": {
  127. "attribution": attribution,
  128. "type": "raster",
  129. "tiles": [url + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
  130. "tileSize": 256,
  131. },
  132. },
  133. "layers": [{
  134. "id": "simple-tiles",
  135. "type": "raster",
  136. "source": "raster-tiles",
  137. "minzoom": 0,
  138. "maxzoom": 22
  139. }]
  140. },
  141. center: [-122.430844, 37.772276],
  142. zoom: 12,
  143. pitch: 60,
  144. bearing: 36
  145. });
  146. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  147. widgets.loader.showLoader("data loading...");
  148. $.get('../data/deck.gl/strees_data.csv', function (csvstr) {
  149. widgets.loader.removeLoader();
  150. var features = Papa.parse(csvstr, {skipEmptyLines: true, header: true});
  151. addLayer(features.data);
  152. });
  153. function addLayer(features) {
  154. var deckglLayer = new mapboxgl.supermap.DeckglLayer("hexagon-layer", {
  155. data: features,
  156. props: {
  157. extruded: true,
  158. radius: 55,
  159. autoHighlight: true,
  160. upperPercentile: 99,
  161. coverage: 0.8,
  162. elevationScale: 400,
  163. colorRange: [[43, 30, 61, 255], [56, 60, 101, 255], [62, 95, 126, 255], [73, 131, 138, 255], [94, 162, 141, 255], [130, 187, 146, 255], [174, 206, 161, 255], [214, 222, 191, 255]],
  164. opacity: 0.8,
  165. // lightSettings 光照配置参数,配置三维光照效果,
  166. lightSettings: {
  167. lightsPosition: [-122.5, 37.7, 3000, -122.2, 37.9, 3000], // 指定为`[x,y,z]`的光在平面阵列中的位置
  168. ambientRatio: 0.2, //光照的环境比例
  169. diffuseRatio: 0.5, //光的漫反射率
  170. specularRatio: 0.3, //光的镜面反射率
  171. lightsStrength: [1.0, 0.0, 2.0, 0.0], //平面阵列中指定为“[x,y]`的灯的强度。 长度应该是`2 x numberOfLights`
  172. numberOfLights: 4 //光照值
  173. },
  174. //如需了解其他配置详情,请查看 DeckglLayer api
  175. onHover: function (feature) {
  176. if (!popup) {
  177. popup = new mapboxgl.Popup({
  178. anchor: 'bottom',
  179. closeButton: false,
  180. offset: {
  181. 'bottom': [0, -10],
  182. }
  183. });
  184. }
  185. if (!feature.object) {
  186. popup.remove();
  187. return;
  188. }
  189. //+" "+feature.lngLat
  190. popup.setHTML("Point Count: " + feature.object.points.length);
  191. popup.setLngLat(map.unproject([feature.x, feature.y]));
  192. popup.addTo(map);
  193. }
  194. },
  195. callback: {
  196. getPosition: function (feature) {
  197. if (!feature.latitude || !feature.longitude) {
  198. return [0, 0]
  199. }
  200. return [Number(feature.longitude), Number(feature.latitude)]
  201. }
  202. }
  203. });
  204. map.addLayer(deckglLayer);
  205. }
  206. </script>
  207. </body>
  208. </html>