03_themeRange.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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_themeRange"></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. url = (window.isLocal ? window.server : "https://iserver.supermap.io")+"/iserver/services/map-china400/rest/maps/China";
  17. new ol.supermap.MapService(url).getMapInfo(function (serviceResult) {
  18. var mapJSONObj = serviceResult.result;
  19. map = new ol.Map({
  20. target: 'map',
  21. controls: ol.control.defaults({attributionOptions: {collapsed: false}})
  22. .extend([new ol.supermap.control.Logo()]),
  23. view: new ol.View({
  24. center: [12406035, 4304933],
  25. zoom: 4,
  26. projection: "EPSG:3857",
  27. multiWorld: true
  28. })
  29. });
  30. options = ol.source.TileSuperMapRest.optionsFromMapJSON(url, mapJSONObj);
  31. var layer = new ol.layer.Tile({
  32. source: new ol.source.TileSuperMapRest(options)
  33. });
  34. map.addLayer(layer);
  35. createTheme();
  36. });
  37. function createTheme() {
  38. var themeRangeItem1, themeRangeItem2,
  39. themeRangeItem3, themeRange;
  40. themeRangeItem1 = new SuperMap.ThemeRangeItem({
  41. start: 0,
  42. end: 500000000000,
  43. style: new SuperMap.ServerStyle({
  44. fillForeColor: new SuperMap.ServerColor(211, 255, 250),
  45. lineColor: new SuperMap.ServerColor(179, 209, 193),
  46. lineWidth: 0.1
  47. })
  48. });
  49. themeRangeItem2 = new SuperMap.ThemeRangeItem({
  50. start: 500000000000,
  51. end: 1000000000000,
  52. style: new SuperMap.ServerStyle({
  53. fillForeColor: new SuperMap.ServerColor(178, 218, 199),
  54. lineColor: new SuperMap.ServerColor(179, 209, 193),
  55. lineWidth: 0.1
  56. })
  57. });
  58. themeRangeItem3 = new SuperMap.ThemeRangeItem({
  59. start: 1000000000000,
  60. end: 3000000000000,
  61. style: new SuperMap.ServerStyle({
  62. fillForeColor: new SuperMap.ServerColor(58, 178, 166),
  63. lineColor: new SuperMap.ServerColor(179, 209, 193),
  64. lineWidth: 0.1
  65. })
  66. });
  67. themeRange = new SuperMap.ThemeRange({
  68. rangeExpression: "SMAREA",
  69. rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
  70. items: [themeRangeItem1, themeRangeItem2, themeRangeItem3]
  71. });
  72. var themeParameters = new SuperMap.ThemeParameters({
  73. datasetNames: ["China_Province_pg"],
  74. dataSourceNames: ["China"],
  75. joinItems: null,
  76. themes: [themeRange]
  77. });
  78. new ol.supermap.ThemeService(url).getThemeInfo(themeParameters, function (serviceResult) {
  79. var result = serviceResult.result;
  80. if (result && result.newResourceID) {
  81. themeLayer = new ol.layer.Tile({
  82. source: new ol.source.TileSuperMapRest({
  83. url: url,
  84. noWrap: true,
  85. cacheEnabled: false,
  86. transparent: true,
  87. layersID: result.newResourceID,
  88. transparent: true
  89. })
  90. });
  91. map.addLayer(themeLayer);
  92. }
  93. });
  94. }
  95. </script>
  96. </body>
  97. </html>