deckglLayer_polygonLayer.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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_polygonLayer"></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. </style>
  26. </head>
  27. <body>
  28. <div id="map"></div>
  29. <script type="text/javascript" include="widgets" src="../js/include-web.js"></script>
  30. <script type="text/javascript" include="deck" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  31. <script type="text/javascript">
  32. var host = window.isLocal ? window.server : 'https://iserver.supermap.io',
  33. url = host + '/iserver/services/map-china400/rest/maps/ChinaDark';
  34. var map, deckglLayer;
  35. var attribution =
  36. "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  37. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  38. " Map Data <span>© <a href='https://uber.github.io/deck.gl' target='_blank'>deck.gl</a></span> ";
  39. map = new mapboxgl.Map({
  40. container: 'map',
  41. style: {
  42. version: 8,
  43. sources: {
  44. 'raster-tiles': {
  45. attribution: attribution,
  46. type: 'raster',
  47. tiles: [url + '/zxyTileImage.png?z={z}&x={x}&y={y}'],
  48. tileSize: 256
  49. }
  50. },
  51. layers: [
  52. {
  53. id: 'simple-tiles',
  54. type: 'raster',
  55. source: 'raster-tiles',
  56. minzoom: 0,
  57. maxzoom: 22
  58. }
  59. ]
  60. },
  61. center: [-122.4628047, 37.7688628],
  62. zoom: 11.5,
  63. pitch: 60,
  64. bearing: 36
  65. });
  66. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  67. widgets.loader.showLoader('data loading...');
  68. $.get('../data/deck.gl/sf-zipcodes.json', function(features) {
  69. widgets.loader.removeLoader();
  70. addLayer(features);
  71. });
  72. function addLayer(features) {
  73. deckglLayer = new mapboxgl.supermap.DeckglLayer('polygon-layer', {
  74. data: features,
  75. props: {
  76. extruded: true, //是否拉伸建筑,可选参数,默认为 false;
  77. stroked: true, //是否绘制边线,可选参数,默认为 true;
  78. filled: true, //是否填充面,可选参数,默认为 true
  79. wireframe: true, //当面被拉伸为建筑时,是否描绘建筑物边线,可选参数,默认为 false;
  80. lineWidthMinPixels: 1 //线宽最小像素值,可选参数,默认为 0;
  81. //该类型可配置的其他参数有:
  82. //elevationScale 海拔比例,可选参数,默认为 1;
  83. //lineWidthScale 线宽比例,可选参数,默认为 1;
  84. //lineWidthMaxPixels 线宽最大像素值,可选参数,默认为 Number.MAX_SAFE_INTEGER;
  85. //lineJointRounded 节点是否绘制为弧形,可选参数,默认为 false;
  86. //lineMiterLimit 节点相对于线宽的最大范围,可选参数,默认为 4,仅在 lineJointRounded 为 false 时有效;
  87. //lineDashJustified 是否虚线形式显示,可选参数,默认为 false,仅在 getLineDashArray() 回调函数被指定时有效;
  88. //fp64 否应以高精度64位模式呈现图层,可选参数,默认为 false;
  89. },
  90. callback: {
  91. getPolygon: function(d) {
  92. return d.contour;
  93. },
  94. getElevation: function(d) {
  95. return d.population / d.area / 10;
  96. },
  97. getFillColor: function(d) {
  98. return [d.population / d.area / 60, 140, 0];
  99. },
  100. getLineColor: function() {
  101. return [80, 80, 80]
  102. },
  103. getLineWidth: 1
  104. }
  105. });
  106. map.addLayer(deckglLayer);
  107. }
  108. </script>
  109. </body>
  110. </html>