InfoWindow.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. <script src="../../dist/index.js"></script>
  9. <link href="../../cesium/Source/Widgets/widgets.css" rel="stylesheet">
  10. <script src="../../cesium/Build/Cesium/Cesium.js"></script>
  11. </head>
  12. <body style="margin: 0; padding: 0;">
  13. <div id="map" style="height: 100vh; width: 100vw;"></div>
  14. <div class="input-card">
  15. <div class="input-item">
  16. <button class="btn" id="btn1" onclick="open1()">open</button>
  17. </div>
  18. <div class="input-item">
  19. <button class="btn" id="btn2" onclick="remove()">移除</button>
  20. </div>
  21. </div>
  22. </body>
  23. <script>
  24. function remove() {
  25. infowIndow.remove();
  26. }
  27. function open1() {
  28. let sContent =
  29. "<div style='margin:0px;background:red;width:100px'><span class='close'>❌</span> sfdhsdhshffs" +
  30. "</div>";
  31. infowIndow.open({
  32. content: sContent,
  33. position: [116.397428,39.90923],
  34. offset: {//偏移量
  35. x: 0,
  36. y: 10
  37. }
  38. })
  39. }
  40. const viewer = new Cesium.Viewer("map", {
  41. // homeButton: false, // 是否显示首页按钮
  42. // geocoder: false, // 是否显示输入地名查找控件
  43. sceneModePicker: false, // 是否显示投影方式控件(包含二维及三维投影)
  44. // baseLayerPicker: false, // 是否显示帮助控件
  45. creditDisplay: false,
  46. // timeline: true,
  47. // infoBox: false, // 是否显示点击要素之后显示的信息
  48. selectionIndicator: false,
  49. imageryProvider: false,
  50. fullscreenButton: false
  51. })
  52. var infowIndow;
  53. function initData() {
  54. let options = {
  55. isMultiple: false,//多个显示框
  56. popClass: 'sss',
  57. selfStyle: true,
  58. }
  59. infowIndow = new CTMapOl.cesiumComponent.InfoWindow(viewer, options, 'map');
  60. }
  61. initData();
  62. </script>
  63. <style>
  64. /*地图*/
  65. .mapDIV {
  66. height: 100vh;
  67. width: 100vw;
  68. z-index: 1;
  69. }
  70. .add-switch {
  71. position: absolute;
  72. right: 30px;
  73. height: 68px;
  74. width: 30px;
  75. bottom: 112px;
  76. background: #FFFFFF 100%;
  77. color: #172537;
  78. border-radius: 4px;
  79. display: flex;
  80. flex-direction: column;
  81. align-items: center;
  82. z-index: 2;
  83. }
  84. .add-s-block {
  85. height: 20px;
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 100%;
  90. line-height: 20px;
  91. font-size: 12px;
  92. margin-bottom: 2px;
  93. color: #172537;
  94. }
  95. .add-zoom {
  96. width: 20px;
  97. height: 20px;
  98. background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
  99. background-size: 100% 100%;
  100. cursor: pointer;
  101. }
  102. .sub-zoom {
  103. width: 20px;
  104. height: 20px;
  105. background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
  106. background-size: 100% 100%;
  107. cursor: pointer;
  108. }
  109. .add-zoom-out {
  110. width: 20px;
  111. height: 20px;
  112. background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
  113. background-size: 100% 100%;
  114. }
  115. .sub-zoom-out {
  116. width: 20px;
  117. height: 20px;
  118. background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
  119. background-size: 100% 100%;
  120. }
  121. .add-s-block.btn-click {
  122. cursor: pointer;
  123. }
  124. .input-card {
  125. position: absolute;
  126. right: 15px;
  127. bottom: 15px;
  128. z-index: 999;
  129. }
  130. </style>
  131. </html>