GTC2017.html 4.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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>GTC2017</title>
  9. <meta name="viewport" content="width=device-width,initial-scale=0.5,maximum-scale=1,user-scalable=no"/>
  10. <script type="text/javascript" include="mapv" src="https://iclient.supermap.io/web/libs/gtc2017/dist/mbgl-include.js"></script>
  11. <script type="text/javascript" src="https://iclient.supermap.io/web/libs/gtc2017/index.js"></script>
  12. </head>
  13. <body>
  14. <div class="loader loader-curtain"></div>
  15. <div id='map'></div>
  16. <script>
  17. var iServerUrl = "https://iserver.supermap.io/iserver/services/map-city/rest/maps/city/tileFeature.mvt?_cache=false&returnAttributes=true&compressTolerance=-1&width=512&height=512&viewBounds={bbox-epsg-3857}";
  18. var buildingLayer, heightField = "floor", ratio = 15, layerId = "buildings",
  19. center = [106.540545, 29.531714];
  20. var map = new mapboxgl.Map({
  21. container: 'map',
  22. style: mapboxgl.supermap.map.getDefaultVectorTileStyle(iServerUrl),
  23. pitch: 60,
  24. bearing: 290,
  25. center: center,
  26. zoom: 12
  27. });
  28. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  29. //加载进度
  30. map.on('styledata', function (evt) {
  31. showLoader();
  32. });
  33. //关闭进度
  34. map.on('render', function (evt) {
  35. evt.target.areTilesLoaded() && removeLoader();
  36. });
  37. map.on('load', function () {
  38. /*绿色风格*/
  39. mapboxgl.supermap.map.setBackground(map, "hsl(47, 26%, 88%)");
  40. mapboxgl.supermap.map.setPaintProperty(map, '水系多边形@city', 'fill', {'fill-color': 'hsl(205, 56%, 73%)'});
  41. mapboxgl.supermap.map.setPaintProperty(map, '植被_多边形_R@city', 'fill', {'fill-color': 'hsl(82, 46%, 72%)', 'fill-opacity': 0.4});
  42. mapboxgl.supermap.map.setPaintProperty(map, ['R_一级道路@city', 'R_二级道路@city'], 'line', {'line-color': '#fff', 'line-width': 2});
  43. mapboxgl.supermap.map.setPaintProperty(map, ['R_三级道路@city', 'R_四级道路@city'], 'line', {'line-color': 'hsl(0, 0%, 97%)', 'line-width': 1});
  44. /*切换蓝色风格*/
  45. mapboxgl.supermap.map.setBackground(map, "#042133");
  46. mapboxgl.supermap.map.setPaintProperty(map, '水系多边形@city', 'fill', {'fill-color': '#021019'});
  47. mapboxgl.supermap.map.setPaintProperty(map, '植被_多边形_R@city', 'fill', {'fill-color': '#021019', 'fill-opacity': 0.4});
  48. mapboxgl.supermap.map.setPaintProperty(map, ['R_一级道路@city', 'R_二级道路@city'], 'line', {'line-color': '#021019', 'line-width': 2});
  49. mapboxgl.supermap.map.setPaintProperty(map, ['R_三级道路@city', 'R_四级道路@city'], 'line', {'line-color': '#021019', 'line-width': 1});
  50. /*加载三维专题图*/
  51. buildingLayer = new mapboxgl.supermap.RankTheme3DLayer(layerId, map, {
  52. // 设置分段
  53. heightField: heightField,
  54. heightStops: [[1, 15], [40, 600]],
  55. colorStops: [
  56. [0, 'rgba(33, 41, 52, 0.8)'], [10, 'rgba(69,117,180, 0.7)'], [15, 'rgba(116,173,209, 0.7)'], [20, 'rgba(171,217,233, 0.7)'],
  57. [25, 'rgba(254,224,144,0.7)'], [30, 'rgba(253,174,97,0.7)'], [35, 'rgba(244,109,67,0.8)'], [40, 'rgba(215,48,39,0.8)']
  58. ],
  59. // 显示图例
  60. showLegend: true,
  61. legendTheme: 'dark',
  62. legendRatio: ratio,
  63. legendTitle: "高度"
  64. });
  65. buildingLayer.setData(buildings).show();
  66. /*加载O-D图*/
  67. var trafficEndPointLayer = new mapboxgl.supermap.MapvLayer(map, mapboxgl.supermap.MapvDataSet.getPoints(trafficPoints), {
  68. fillStyle: 'rgba(143,242,249,0.8)', shadowColor: 'rgba(65,105,225,1)', shadowBlur: 10, size: 3, draw: 'simple'
  69. });
  70. var trafficTimePointLayer = new mapboxgl.supermap.MapvLayer(map, mapboxgl.supermap.MapvDataSet.getCurveDynamicPoints(center, trafficPoints), {
  71. fillStyle: 'rgba(143,242,249,0.8)', globalCompositeOperation: "lighter", size: 2,
  72. animation: {type: 'time', stepsRange: {start: 0, end: 50}, trails: 10, duration: 5},
  73. draw: 'simple'
  74. });
  75. var trafficLineLayer = new mapboxgl.supermap.MapvLayer(map, mapboxgl.supermap.MapvDataSet.getCurveLines(center, trafficPoints), {
  76. strokeStyle: 'rgba(32,228,243, 0.8)', shadowColor: 'rgba(65,105,225, 0.8)', shadowBlur: 10, lineWidth: 1, draw: 'simple'
  77. });
  78. var trafficCenterLayer = new mapboxgl.supermap.MapvLayer(map, mapboxgl.supermap.MapvDataSet.getPoint(center), {
  79. fillStyle: 'rgba(192,16,26, 0.8)', shadowColor: 'rgba(192,16,26,1)', shadowBlur: 20, size: 6, draw: 'simple'
  80. });
  81. map.setMaxZoom(13.4)
  82. });
  83. </script>
  84. </body>
  85. </html>