components_heatmap_vue.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_componentsHeatmap_Vue"></title>
  9. <script type="text/javascript" include="vue,jquery,papaparse" src="../js/include-web.js"></script>
  10. <script include="iclient-mapboxgl-vue,mapbox-gl-enhance" src="../../dist/mapboxgl/include-mapboxgl.js"></script>
  11. <style>
  12. #main {
  13. margin: 0 auto;
  14. width: 100%;
  15. height: 100%;
  16. }
  17. </style>
  18. </head>
  19. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  20. <div id="main">
  21. <sm-web-map :map-options="mapOptions">
  22. <sm-heatmap-layer :data="data" :layer-style="heatMapStyle"></sm-heatmap-layer>
  23. </sm-web-map>
  24. </div>
  25. <script>
  26. var heatFeatures = [],
  27. heatMapSource,
  28. heatMapStyle;
  29. $.get("../data/chinaEarthquake.csv", function(csvstr) {
  30. var data = Papa.parse(csvstr, { skipEmptyLines: true, header: true }).data;
  31. for (var i = 0; i < data.length; i += 6) {
  32. if (data[i].Y <= 85) {
  33. heatFeatures.push({
  34. geometry: {
  35. coordinates: [parseFloat(data[i].X), parseFloat(data[i].Y)],
  36. type: "Point"
  37. },
  38. properties: { value: data[i].level / 50, id: i },
  39. type: "Feature"
  40. });
  41. }
  42. }
  43. heatMapStyle = new SuperMap.Components.commontypes.HeatMapStyle({
  44. "heatmap-intensity": ["interpolate", ["linear"], ["zoom"], 0, 1, 9, 3],
  45. "heatmap-color": [
  46. "interpolate",
  47. ["linear"],
  48. ["heatmap-density"],
  49. 0,
  50. "rgba(33,102,172,0)",
  51. 0.2,
  52. "rgb(103,169,207)",
  53. 0.4,
  54. "rgb(209,229,240)",
  55. 0.6,
  56. "rgb(253,219,199)",
  57. 0.8,
  58. "rgb(239,138,98)",
  59. 1,
  60. "rgb(178,24,43)"
  61. ],
  62. "heatmap-radius": ["interpolate", ["linear"], ["zoom"], 0, 2, 9, 20],
  63. "heatmap-opacity": ["interpolate", ["linear"], ["zoom"], 7, 1, 9, 0]
  64. });
  65. new Vue({
  66. el: "#main",
  67. data() {
  68. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  69. var attribution =
  70. "<a href='https://www.mapbox.com/about/maps/' target='_blank'>© Mapbox </a>" +
  71. " with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a> | </span>" +
  72. " Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> ";
  73. return {
  74. data: {
  75. type: "FeatureCollection",
  76. features: heatFeatures
  77. },
  78. heatMapStyle: heatMapStyle,
  79. mapOptions: {
  80. container: "map", // container id
  81. style: {
  82. version: 8,
  83. sources: {
  84. "raster-tiles": {
  85. attribution: attribution,
  86. type: "raster",
  87. tiles: [
  88. host +
  89. "/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}"
  90. ],
  91. tileSize: 256
  92. }
  93. },
  94. layers: [
  95. {
  96. id: "simple-tiles",
  97. type: "raster",
  98. source: "raster-tiles",
  99. minzoom: 0,
  100. maxzoom: 22
  101. }
  102. ]
  103. },
  104. center: [120.143, 30.236],
  105. zoom: 3
  106. }
  107. };
  108. }
  109. });
  110. });
  111. </script>
  112. </body>
  113. </html>