deckglLayer_nyc_census.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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_nyc_census"></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(
  46. to right,
  47. rgba(114, 159, 207, 1),
  48. rgba(104, 104, 104, 1) 200px,
  49. rgba(104, 104, 104, 0) 75%
  50. )
  51. 30;
  52. }
  53. .legendContainer {
  54. position: absolute;
  55. bottom: 25px;
  56. right: 25px;
  57. color: white;
  58. padding: 10px 10px 0 10px;
  59. z-index: 1000;
  60. }
  61. .legendHead {
  62. align-self: flex-end;
  63. }
  64. .legendBody {
  65. padding-top: 10px;
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <div id="title">
  71. <h3 data-i18n="resources.title_mb_deckglLayer_nyc_census"></h3>
  72. <h6 data-i18n="resources.text_mb_deckglLayer_nyc_census"></h6>
  73. </div>
  74. <div class="legendContainer whiteBackground">
  75. <div class="legendHead _flex">
  76. <div>NYC 2010 Census Tracts</div>
  77. <div>Polygon color</div>
  78. <div>by Population</div>
  79. </div>
  80. <div class="legendBody _flex">
  81. <svg width="180" height="200">
  82. <g transform="translate(0, 0)">
  83. <rect width="30" height="20" style="fill: rgb(25, 66, 102);"></rect>
  84. <text x="38" y="14" fill="white">[ 0, 1670.5 ]</text>
  85. </g>
  86. <g transform="translate(0, 24)">
  87. <rect width="30" height="20" style="fill: rgb(53, 92, 125);"></rect>
  88. <text x="38" y="14" fill="white">( 1670.5, 2259.0]</text>
  89. </g>
  90. <g transform="translate(0, 48)">
  91. <rect width="30" height="20" style="fill: rgb(99, 97, 127);"></rect>
  92. <text x="38" y="14" fill="white">( 2259.0, 2862.88]</text>
  93. </g>
  94. <g transform="translate(0, 72)">
  95. <rect width="30" height="20" style="fill: rgb(145, 102, 129);"></rect>
  96. <text x="38" y="14" fill="white">( 2862.88, 3426.50]</text>
  97. </g>
  98. <g transform="translate(0, 96)">
  99. <rect width="30" height="20" style="fill: rgb(192, 108, 132);"></rect>
  100. <text x="38" y="14" fill="white">( 3426.50, 4013.25 ]</text>
  101. </g>
  102. <g transform="translate(0, 120)">
  103. <rect width="30" height="20" style="fill: rgb(210, 131, 137);"></rect>
  104. <text x="38" y="14" fill="white">( 4013.25, 4814.00 ]</text>
  105. </g>
  106. <g transform="translate(0, 144)">
  107. <rect width="30" height="20" style="fill: rgb(229, 154, 143);"></rect>
  108. <text x="38" y="14" fill="white">( 4814.00, 6204.25 ]</text>
  109. </g>
  110. <g transform="translate(0, 168)">
  111. <rect width="30" height="20" style="fill: rgb(248, 177, 149);"></rect>
  112. <text x="38" y="14" fill="white">( 6204.25, 26588.00 ]</text>
  113. </g>
  114. </svg>
  115. </div>
  116. </div>
  117. <div id="map"></div>
  118. <script
  119. type="text/javascript"
  120. include="jquery,bootstrap,papaparse,dat-gui,widgets"
  121. src="../js/include-web.js"
  122. ></script>
  123. <script type="text/javascript" include="deck" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  124. <script type="text/javascript">
  125. var host = window.isLocal ? window.server : 'https://iserver.supermap.io',
  126. url = host + '/iserver/services/map-china400/rest/maps/ChinaDark';
  127. var map, deckglLayer;
  128. var attribution =
  129. "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  130. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  131. " Map Data <span>© <a href='https://uber.github.io/kepler.gl' target='_blank'>kepler.gl</a></span> ";
  132. map = new mapboxgl.Map({
  133. container: 'map',
  134. style: {
  135. version: 8,
  136. sources: {
  137. 'raster-tiles': {
  138. attribution: attribution,
  139. type: 'raster',
  140. tiles: [url + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
  141. tileSize: 256
  142. }
  143. },
  144. layers: [
  145. {
  146. id: 'simple-tiles',
  147. type: 'raster',
  148. source: 'raster-tiles',
  149. minzoom: 0,
  150. maxzoom: 22
  151. }
  152. ]
  153. },
  154. center: [-73.83429, 40.725818],
  155. zoom: 11.5,
  156. pitch: 60,
  157. bearing: -100
  158. });
  159. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  160. widgets.loader.showLoader('data loading...');
  161. $.get('../data/deck.gl/nyc_census_data.json', function(features) {
  162. widgets.loader.removeLoader();
  163. addLayer(features.features);
  164. });
  165. function addLayer(features) {
  166. deckglLayer = new mapboxgl.supermap.DeckglLayer('polygon-layer', {
  167. data: features,
  168. props: {
  169. stroked: false,
  170. extruded: true,
  171. filled: true,
  172. opacity: 0.7,
  173. autoHighlight: true,
  174. highlightColor: [255, 255, 0, 255],
  175. lightSettings: {
  176. lightsPosition: [-73, 40, 5000, -74, 41, 5000],
  177. ambientRatio: 0.2,
  178. diffuseRatio: 0.5,
  179. specularRatio: 0.3,
  180. lightsStrength: [1.0, 0.0, 2.0, 0.0],
  181. numberOfLights: 2
  182. }
  183. },
  184. callback: {
  185. getPolygon: function(feature) {
  186. if (!feature.geometry || !feature.geometry.coordinates) {
  187. return [0, 0];
  188. }
  189. return feature.geometry.coordinates;
  190. },
  191. getElevation: function(d) {
  192. return d.properties.Population / 8;
  193. },
  194. getFillColor: function(feature) {
  195. if (feature.properties.Population >= 0 && feature.properties.Population < 1670.5) {
  196. return [25, 66, 102];
  197. } else if (feature.properties.Population >= 1670.5 && feature.properties.Population < 2259.0) {
  198. return [53, 92, 125];
  199. } else if (feature.properties.Population >= 2259.0 && feature.properties.Population < 2862.88) {
  200. return [99, 97, 127];
  201. } else if (feature.properties.Population >= 2862.88 && feature.properties.Population < 3426.5) {
  202. return [145, 102, 129];
  203. } else if (feature.properties.Population >= 3426.5 && feature.properties.Population < 4013.25) {
  204. return [192, 108, 132];
  205. } else if (feature.properties.Population >= 4013.25 && feature.properties.Population < 4814.0) {
  206. return [210, 131, 137];
  207. } else if (feature.properties.Population >= 4814.0 && feature.properties.Population < 6204.25) {
  208. return [229, 154, 143];
  209. } else if (feature.properties.Population >= 6204.25) {
  210. return [248, 177, 149];
  211. }
  212. return [0, 0, 0, 0];
  213. }
  214. }
  215. });
  216. map.addLayer(deckglLayer);
  217. }
  218. </script>
  219. </body>
  220. </html>