03_themeGraph.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
  11. </head>
  12. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%; position: absolute;top: 0;">
  13. <div id="map" style="width: 100%;height:100%"></div>
  14. <script type="text/javascript">
  15. var map, themeLayer, options,
  16. host = (window.isLocal ? window.server : "https://iserver.supermap.io"),
  17. mapUrl = host + "/iserver/services/map-jingjin/rest/maps/京津地区地图",
  18. url = host + "/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图";
  19. var mapService = new ol.supermap.MapService(url);
  20. mapService.getMapInfo(function (serviceResult) {
  21. var mapJSONObj = serviceResult.result;
  22. map = new ol.Map({
  23. target: 'map',
  24. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  25. .extend([new ol.supermap.control.Logo()]),
  26. view: new ol.View({
  27. center: [117, 40],
  28. zoom: 7,
  29. projection: "EPSG:4326",
  30. multiWorld: true
  31. })
  32. });
  33. options = ol.source.TileSuperMapRest.optionsFromMapJSON(mapUrl, mapJSONObj);
  34. var layer = new ol.layer.Tile({
  35. source: new ol.source.TileSuperMapRest(options)
  36. });
  37. map.addLayer(layer)
  38. createTheme();
  39. });
  40. function createTheme() {
  41. var themeGraph = new SuperMap.ThemeGraph({
  42. items: [
  43. new SuperMap.ThemeGraphItem({
  44. caption: "1992-1995人口增长率",
  45. graphExpression: "Pop_Rate95",
  46. uniformStyle: new SuperMap.ServerStyle({
  47. fillForeColor: new SuperMap.ServerColor(92, 73, 234),
  48. lineWidth: 0.1
  49. })
  50. }),
  51. new SuperMap.ThemeGraphItem({
  52. caption: "1995-1999人口增长率",
  53. graphExpression: "Pop_Rate99",
  54. uniformStyle: new SuperMap.ServerStyle({
  55. fillForeColor: new SuperMap.ServerColor(211, 111, 240),
  56. lineWidth: 0.1
  57. })
  58. })
  59. ],
  60. barWidth: 0.03,
  61. graduatedMode: SuperMap.GraduatedMode.SQUAREROOT,
  62. graphAxes: new SuperMap.ThemeGraphAxes({
  63. axesDisplayed: true
  64. }),
  65. graphSize: new SuperMap.ThemeGraphSize({
  66. maxGraphSize: 1,
  67. minGraphSize: 0.35
  68. }),
  69. graphText: new SuperMap.ThemeGraphText({
  70. graphTextDisplayed: true,
  71. graphTextFormat: SuperMap.ThemeGraphTextFormat.VALUE,
  72. graphTextStyle: new SuperMap.ServerTextStyle({
  73. sizeFixed: true,
  74. fontHeight: 9,
  75. fontWidth: 5
  76. })
  77. }),
  78. graphType: SuperMap.ThemeGraphType.BAR3D
  79. });
  80. var themeParameters = new SuperMap.ThemeParameters({
  81. themes: [themeGraph],
  82. dataSourceNames: ["Jingjin"],
  83. datasetNames: ["BaseMap_R"]
  84. });
  85. var extent = [114.59, 37.76, 119.51, 42.31];
  86. new ol.supermap.ThemeService(url).getThemeInfo(themeParameters, function (serviceResult) {
  87. var result = serviceResult.result;
  88. if (result && result.newResourceID) {
  89. themeLayer = new ol.layer.Tile({
  90. source: new ol.source.TileSuperMapRest({
  91. url: url,
  92. noWrap: true,
  93. cacheEnabled: false,
  94. tileGrid: new ol.tilegrid.TileGrid({
  95. extent: extent,
  96. resolutions: options.tileGrid.getResolutions()
  97. }),
  98. layersID: result.newResourceID,
  99. transparent: true
  100. })
  101. });
  102. map.addLayer(themeLayer);
  103. }
  104. });
  105. }
  106. </script>
  107. </body>
  108. </html>