03_themeGraph.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_themeGraph"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="title" style="position:absolute;top: 10px;text-align:center;width:100%;z-index: 10;color: #f7931e" data-i18n="resources.text_GDPStatistic"></div>
  13. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  14. <script type="text/javascript" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  15. <span id="show"></span>
  16. <script type="text/javascript">
  17. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  18. var attribution = "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  19. "with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  20. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  21. var dataUrl = host + "/iserver/services/map-china400/rest/maps/China";
  22. var map = new mapboxgl.Map({
  23. container: 'map',
  24. style: {
  25. "version": 8,
  26. "sources": {
  27. "raster-tiles": {
  28. "attribution": attribution,
  29. "type": "raster",
  30. "tiles": [host + '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?&z={z}&x={x}&y={y}'],
  31. "tileSize": 256,
  32. },
  33. },
  34. "layers": [{
  35. "id": "simple-tiles",
  36. "type": "raster",
  37. "source": "raster-tiles",
  38. "minzoom": 0,
  39. "maxzoom": 22
  40. }]
  41. },
  42. center: [104, 38],
  43. zoom: 3.55
  44. });
  45. map.addControl(new mapboxgl.NavigationControl(), 'top-left');
  46. map.addControl(new mapboxgl.supermap.LogoControl(), 'bottom-right');
  47. function createTheme() {
  48. themeGraph = new SuperMap.ThemeGraph({
  49. items: [
  50. new SuperMap.ThemeGraphItem({
  51. caption: "全国省份2013_GDP",
  52. graphExpression: "GDP_2013",
  53. uniformStyle: new SuperMap.ServerStyle({
  54. fillForeColor: new SuperMap.ServerColor(255, 215, 0),
  55. lineWidth: 0
  56. })
  57. }),
  58. new SuperMap.ThemeGraphItem({
  59. caption: "全国省份2014_GDP",
  60. graphExpression: "GDP_2014",
  61. uniformStyle: new SuperMap.ServerStyle({
  62. fillForeColor: new SuperMap.ServerColor(0, 191, 255),
  63. lineWidth: 0
  64. })
  65. }),
  66. ],
  67. barWidth: 0.001,
  68. graduatedMode: SuperMap.GraduatedMode.CONSTANT,
  69. graphAxes: new SuperMap.ThemeGraphAxes({
  70. axesDisplayed: true
  71. }),
  72. graphSize: new SuperMap.ThemeGraphSize({
  73. maxGraphSize: 500000,
  74. minGraphSize: 200000
  75. }),
  76. graphText: new SuperMap.ThemeGraphText({
  77. graphTextDisplayed: true,
  78. graphTextFormat: SuperMap.ThemeGraphTextFormat.VALUE,
  79. graphTextStyle: new SuperMap.ServerTextStyle({
  80. fontHeight: 10,
  81. fontWidth: 10
  82. })
  83. }),
  84. overlapAvoided: false,
  85. graphSizeFixed: false,
  86. graphType: SuperMap.ThemeGraphType.BAR
  87. });
  88. themeParameters = new SuperMap.ThemeParameters({
  89. themes: [themeGraph],
  90. datasetNames: ["China_Province_pg"],
  91. dataSourceNames: ["China"]
  92. });
  93. new mapboxgl.supermap.ThemeService(dataUrl).getThemeInfo(themeParameters, function (serviceResult) {
  94. var result = serviceResult.result;
  95. if (result && result.newResourceID) {
  96. map.addSource("theme", {
  97. "type": 'raster',
  98. "tiles": [host + '/iserver/services/map-china400/rest/maps/China/zxyTileImage.png?z={z}&x={x}&y={y}&transparent=true&cacheEnabled=false&layersID=' + result.newResourceID],
  99. "tileSize": 256,
  100. });
  101. map.addLayer({
  102. "id": "themeLayer",
  103. "type": "raster",
  104. "source": "theme",
  105. });
  106. }
  107. })
  108. }
  109. map.on('load', function () {
  110. createTheme();
  111. });
  112. </script>
  113. </body>
  114. </html>