m30_echarts_lineroad.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  6. <meta name="author" content="火星科技 http://mars3d.cn " />
  7. <meta name="apple-touch-fullscreen" content="yes" />
  8. <meta name="apple-mobile-web-app-capable" content="yes" />
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  10. <meta name="format-detection" content="telephone=no" />
  11. <meta name="x5-fullscreen" content="true" />
  12. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
  13. <!-- 标题及搜索关键字 -->
  14. <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
  15. <meta
  16. name="description"
  17. content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型 gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包 地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
  18. />
  19. <link rel="shortcut icon" type="image/x-icon" href="" />
  20. <title>道路拥堵图| Echarts扩展支持 | 三维地图 </title>
  21. <!--第三方lib-->
  22. <script
  23. type="text/javascript"
  24. src="../lib/include-lib.js"
  25. libpath="../lib/"
  26. include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d,mars3d-echarts"
  27. ></script>
  28. <link href="css/style.css" rel="stylesheet" />
  29. </head>
  30. <body class="dark">
  31. <!--加载前进行操作提示,优化用户体验-->
  32. <div id="mask" class="signmask" onclick="removeMask()"></div>
  33. <div id="mars3dContainer" class="mars3d-container"></div>
  34. <script src="./js/common.js"></script>
  35. <script type="text/javascript">
  36. "use script"; //开发环境建议开启严格模式
  37. var map;
  38. function initMap(options) {
  39. //合并属性参数,可覆盖config.json中的对应配置
  40. var mapOptions = mars3d.Util.merge(options, {
  41. scene: {
  42. center: { lat: 30.589203, lng: 120.732051, alt: 18446, heading: 2, pitch: -49 },
  43. },
  44. });
  45. //创建三维地球场景
  46. map = new mars3d.Map("mars3dContainer", mapOptions);
  47. queryLineroadApiData().then(function (res) {
  48. //创建Echarts图层
  49. createEchartsLayer(res.data);
  50. });
  51. }
  52. // 访问后端接口,取数据
  53. function queryLineroadApiData() {
  54. return new Promise(function (resolve, reject) {
  55. $.get("//data.mars3d.cn/file/apidemo/lineroad.json", function (result) {
  56. resolve(result);
  57. });
  58. });
  59. }
  60. function createEchartsLayer(data) {
  61. var options = getEchartsOption(data);
  62. options.depthTest = false; //是否进行计算深度(大数据时,需要关闭)
  63. var echartsLayer = new mars3d.layer.EchartsLayer(options);
  64. map.addLayer(echartsLayer);
  65. }
  66. function getEchartsOption(data) {
  67. var option = {
  68. animation: false,
  69. visualMap: {
  70. type: "piecewise",
  71. left: "right",
  72. top: "bottom",
  73. /* pieces: [
  74. {min: 15}, // 不指定 max,表示 max 为无限大(Infinity)。
  75. {min: 12, max: 15},
  76. {min: 9, max: 12},
  77. {min: 6, max: 9},
  78. {min: 3, max: 6},
  79. {max: 3} // 不指定 min,表示 min 为无限大(-Infinity)。
  80. ],*/
  81. min: 0,
  82. max: 15,
  83. splitNumber: 5,
  84. maxOpen: true,
  85. color: ["red", "yellow", "green"],
  86. textStyle: {
  87. color: "#ffffff",
  88. },
  89. },
  90. tooltip: {
  91. formatter: function (params, ticket, callback) {
  92. return "拥堵指数:" + params.value;
  93. },
  94. trigger: "item",
  95. },
  96. series: [
  97. {
  98. type: "lines",
  99. coordinateSystem: "mars3dMap",
  100. polyline: true,
  101. data: data,
  102. lineStyle: {
  103. normal: {
  104. opacity: 1,
  105. width: 4,
  106. },
  107. emphasis: {
  108. width: 6,
  109. },
  110. },
  111. effect: {
  112. show: true,
  113. symbolSize: 2,
  114. color: "white",
  115. },
  116. },
  117. ],
  118. };
  119. return option;
  120. }
  121. </script>
  122. </body>
  123. </html>