f45_polyGradient.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!-- 2017-12-7 14:56:03 | 修改 木遥(微信: http://marsgis.cn/weixin.html ) -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
  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>渐变区域 </title>
  21. <script
  22. type="text/javascript"
  23. src="../lib/include-lib.js"
  24. libpath="../lib/"
  25. include="jquery,font-awesome,bootstrap,layer,haoutil,turf,mars3d"
  26. ></script>
  27. <link href="css/style.css" rel="stylesheet" />
  28. </head>
  29. <body class="dark">
  30. <!--加载前进行操作提示,优化用户体验-->
  31. <div id="mask" class="signmask" onclick="removeMask()"></div>
  32. <div id="mars3dContainer" class="mars3d-container"></div>
  33. <script src="./js/common.js"></script>
  34. <script type="text/javascript">
  35. "use script"; //开发环境建议开启严格模式
  36. var map;
  37. function initMap(options) {
  38. //合并属性参数,可覆盖config.json中的对应配置
  39. var mapOptions = mars3d.Util.merge(options, {
  40. scene: {
  41. center: { lat: 26.339073, lng: 118.495643, alt: 937783, heading: 355, pitch: -58 },
  42. },
  43. });
  44. //创建三维地球场景
  45. map = new mars3d.Map("mars3dContainer", mapOptions);
  46. map.basemap = 2017; //蓝色底图
  47. let geoJsonLayer = new mars3d.layer.GeoJsonLayer({
  48. name: "安徽各市",
  49. url: "//data.mars3d.cn/file/geojson/areas/340000_full.json",
  50. symbol: {
  51. type: "polygon",
  52. styleOptions: {
  53. materialType: mars3d.MaterialType.PolyGradient, //重要参数,指定材质
  54. color: "#3388cc",
  55. opacity: 0.7,
  56. alphaPower: 1.3,
  57. //面中心点,显示文字的配置
  58. label: {
  59. text: "{name}", //对应的属性名称
  60. opacity: 1,
  61. font_size: 25,
  62. color: "#fff",
  63. font_family: "楷体",
  64. outline: false,
  65. scaleByDistance: true,
  66. scaleByDistance_far: 20000000,
  67. scaleByDistance_farValue: 0.1,
  68. scaleByDistance_near: 1000,
  69. scaleByDistance_nearValue: 1,
  70. },
  71. },
  72. callback: function (attr, styleOpt) {
  73. let randomHeight = attr.gdp * 5; //测试的高度
  74. return {
  75. color: getColor(),
  76. diffHeight: randomHeight,
  77. };
  78. },
  79. },
  80. popup: "{name} : {gdp}亿元 ",
  81. });
  82. map.addLayer(geoJsonLayer);
  83. //绑定事件
  84. geoJsonLayer.on(mars3d.EventType.load, function (event) {
  85. console.log("数据加载完成", event);
  86. });
  87. geoJsonLayer.on(mars3d.EventType.click, function (event) {
  88. console.log("单击了图层", event);
  89. });
  90. }
  91. let arrColor = ["rgb(15,176,255)", "rgb(18,76,154)", "#40C4E4", "#42B2BE", "rgb(51,176,204)", "#8CB7E5", "rgb(0,244,188)", "#139FF0"];
  92. let index = 0;
  93. function getColor() {
  94. return arrColor[++index % arrColor.length];
  95. }
  96. </script>
  97. </body>
  98. </html>