07thrdimeslectregionmap.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>行政区划立体显示</title>
  7. <link rel="stylesheet" href="../dist/index.css" />
  8. <link href="../cesium/Source/Widgets/widgets.css" rel="stylesheet">
  9. <script src="../cesium/Build/Cesium/Cesium.js"></script>
  10. <script src="../dist/index.js"></script>
  11. <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  12. <style>
  13. * {
  14. padding: 0;
  15. margin: 0;
  16. }
  17. .regionSelect {
  18. position: absolute;
  19. top: 0px;
  20. }
  21. </style>
  22. </head>
  23. <body>
  24. <div id="map" style="height: 100vh; width: 100vw;"></div>
  25. <div class="regionSelect">
  26. <select name="region" id="region"></select>
  27. </div>
  28. </body>
  29. <script>
  30. window.CESIUM_BASE_URL = '../cesium/Build/Cesium';
  31. Cesium.Ion.defaultAccessToken =
  32. 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2MjIyODA4ZS0zNmRmLTQwNGMtYjZkNC0wOGY2NDdmODgyZTUiLCJpZCI6ODMyOCwiaWF0IjoxNjA2MjkyNDE1fQ.ZhhxNIJ-TzstpcavQBNL7xRwytBat3G2__3jr7lJ8yg'
  33. let op = CTMapOl.thrdime.viewercontrol.globalvieweroptions()
  34. op.sceneMode = Cesium.SceneMode.COLUMBUS_VIEW
  35. var viewer = CTMapOl.thrdime.viewercontrol.globalviewer('map', op)
  36. viewer._cesiumWidget._creditContainer.style.display = 'none'
  37. CTMapOl.thrdime.imagerylayercontrol.removeAll(viewer, true)
  38. CTMapOl.thrdime.cameracontrol.setcamera(viewer, CTMapOl.thrdime.cameracontrol.getcameraoptionswithdetile(116.39,
  39. 39.91, 5000, 0, -90, 0))
  40. // 背景透明
  41. viewer.scene.globe.showGroundAtmosphere = false;
  42. viewer.scene.globe.baseColor = Cesium.Color.TRANSPARENT;
  43. viewer.scene.globe.translucency.enabled = true;
  44. viewer.scene.globe.undergroundColor = undefined;
  45. // 显示行政区划数据
  46. let SelectCodeGetRegion = new CTMapOl.cesiumComponent.SelectCodeGetRegion(viewer)
  47. SelectCodeGetRegion.active(100000)
  48. // 获取下拉行政区划
  49. fullfillregion(100000)
  50. var regionSelect = document.getElementById("region");
  51. // 点击下拉框切换数据
  52. regionSelect.addEventListener('change', function () {
  53. var selectedOption = regionSelect.options[regionSelect.selectedIndex];
  54. console.log(selectedOption.value);
  55. SelectCodeGetRegion.clear()
  56. SelectCodeGetRegion.active(selectedOption.value)
  57. fullfillregion(selectedOption.value)
  58. });
  59. async function fullfillregion(code) {
  60. var regiondata = await CTMapOl.getRegionGeojson(code)
  61. regionSelect.options.length = 0
  62. regiondata.childregion.features.forEach(item => {
  63. var option = document.createElement("option");
  64. option.value = item.properties.adcode
  65. option.text = item.properties.name;
  66. regionSelect.add(option);
  67. })
  68. }
  69. </script>
  70. </html>