InforWindow.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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>三维-信息窗体2</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="">open</button>-->
  17. </div>
  18. <div class="input-item">
  19. <button class="btn" id="remove" >隐藏</button>
  20. <button class="btn" id="show" >显示</button>
  21. <button class="btn" id="destroy" >销毁</button>
  22. <button class="btn" id="setAnchor" >改变位置</button>
  23. </div>
  24. </div>
  25. </body>
  26. <script>
  27. let map = new CTMapOl.cesiumComponent.ThrdimeInitMap({
  28. domId: 'map',
  29. // center: [-87.14045498433224, 44.604935926720024],
  30. center: [112.852222,
  31. 29.773889],
  32. zoom: 4
  33. })
  34. let viewer = map._viewer;
  35. var infowIndow;
  36. function initData() {
  37. let sContent =
  38. "<div style='margin:0px;background:red;width:100px'><span class='close'>❌</span> sfdhsdhshffs" +
  39. "</div>";
  40. let options = {
  41. content: sContent,
  42. position: [116.397428,39.90923],
  43. anchor: ['100%', '100%'],
  44. offset: [0, 0],
  45. rotate: 0,
  46. className: 'prompt',
  47. autoAnchor: true,
  48. icon: {
  49. size: [50, 50],
  50. offset: [25, 25],
  51. }
  52. }
  53. infowIndow = new CTMapOl.cesiumComponent.InforWindow(viewer, options);
  54. document.getElementById('remove').onclick = e => {
  55. infowIndow.remove();
  56. }
  57. document.getElementById('show').onclick = e => {
  58. infowIndow.appear();
  59. }
  60. document.getElementById('destroy').onclick = e => {
  61. infowIndow.destroy();
  62. }
  63. document.getElementById('setAnchor').onclick = e => {
  64. infowIndow.setAnchor([0, '100%']);
  65. }
  66. let p = new CTMapOl.cesiumComponent.Point(viewer, {
  67. lng: 116.397428,
  68. lat: 39.90923,
  69. id: "123",
  70. imgPath: '../assets/image/rect.jpg',
  71. iconSize: [50, 50],
  72. offset: [25, 25],
  73. clickBig: false,
  74. clickIcon: '../assets/image/rect2.jpg',
  75. zIndex: 1,
  76. });
  77. }
  78. initData();
  79. </script>
  80. <style>
  81. /*地图*/
  82. .mapDIV {
  83. height: 100vh;
  84. width: 100vw;
  85. z-index: 1;
  86. }
  87. .add-switch {
  88. position: absolute;
  89. right: 30px;
  90. height: 68px;
  91. width: 30px;
  92. bottom: 112px;
  93. background: #FFFFFF 100%;
  94. color: #172537;
  95. border-radius: 4px;
  96. display: flex;
  97. flex-direction: column;
  98. align-items: center;
  99. z-index: 2;
  100. }
  101. .add-s-block {
  102. height: 20px;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. width: 100%;
  107. line-height: 20px;
  108. font-size: 12px;
  109. margin-bottom: 2px;
  110. color: #172537;
  111. }
  112. .add-zoom {
  113. width: 20px;
  114. height: 20px;
  115. background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
  116. background-size: 100% 100%;
  117. cursor: pointer;
  118. }
  119. .sub-zoom {
  120. width: 20px;
  121. height: 20px;
  122. background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
  123. background-size: 100% 100%;
  124. cursor: pointer;
  125. }
  126. .add-zoom-out {
  127. width: 20px;
  128. height: 20px;
  129. background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
  130. background-size: 100% 100%;
  131. }
  132. .sub-zoom-out {
  133. width: 20px;
  134. height: 20px;
  135. background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
  136. background-size: 100% 100%;
  137. }
  138. .add-s-block.btn-click {
  139. cursor: pointer;
  140. }
  141. .input-card {
  142. position: absolute;
  143. right: 15px;
  144. bottom: 15px;
  145. z-index: 999;
  146. }
  147. </style>
  148. </html>