Points.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="lightPoint">根据id高亮点</button>
  17. </div>
  18. <div class="input-item">
  19. <button class="btn" id="origin" onclick="origin()">还原</button>
  20. </div>
  21. <div class="input-item">
  22. <button class="btn" id="remove">移除</button>
  23. </div>
  24. <div class="input-item">
  25. <button class="btn" id="restore" onclick="restore()">还原状态</button>
  26. </div>
  27. </div>
  28. </body>
  29. <script>
  30. function origin() {
  31. points.repeatSize();
  32. }
  33. function lightPoint() {
  34. points.locationById({ id: "12332" });
  35. }
  36. function remove() {
  37. points.remove();
  38. }
  39. function restore() {
  40. points.restore();
  41. }
  42. let map = new CTMapOl.cesiumComponent.ThrdimeInitMap({
  43. domId: 'map',
  44. center: [103.230695,35.624892],
  45. zoom: 15
  46. })
  47. let viewer = map._viewer;
  48. var points;
  49. function initData() {
  50. let options = {
  51. viewer,
  52. layerId: 'DataSourceLayer',
  53. points: [
  54. ['103.230695,35.624892', 'aaa', '../assets/monitor-online.png', '25,25', 1],
  55. // ['120.12,31.21', 'bbb', '../assets/image/rect.jpg', '0,0', 1]
  56. ],
  57. // clickOption: [
  58. // {big: true, icon: '../assets/image/rect2.jpg'},
  59. // {big: true}
  60. // ],
  61. width: 50,
  62. height: 50,
  63. clickIcon: '../assets/image/rect2.jpg',
  64. clickBig: false,
  65. // zoom: 2, // 超过2级就显示
  66. // maxZoom: 5,
  67. // remark: {
  68. // fontSize: 24,
  69. // color: 'green',
  70. // offset: [0, 0],
  71. // },
  72. zIndex: 9
  73. }
  74. points = new CTMapOl.cesiumComponent.Points(options);
  75. points.addTo({ viewer: viewer })
  76. points.on('click', e => {
  77. console.log(e)
  78. })
  79. points.on('mousemove', e => {
  80. console.log(e)
  81. })
  82. document.getElementById('remove').onclick = () => {
  83. points.remove();
  84. }
  85. document.getElementById('lightPoint').onclick = () => {
  86. points.locationById({id: '12332'});
  87. }
  88. }
  89. initData();
  90. function initData2() {
  91. let options = {
  92. viewer,
  93. layerId: 'DataSourceLayer',
  94. points: [
  95. ['120.12,31.21', '12332', '../assets/image/rect.jpg', '15,15', 2],
  96. ['120.12,31.21', 'bb23424b', '../assets/image/rect.jpg', '0,0', 2]
  97. ],
  98. // clickOption: [
  99. // {big: false, icon: '../assets/image/rect2.jpg'},
  100. // {big: false}
  101. // ],
  102. width: 30,
  103. height: 30,
  104. clickIcon: '../assets/image/rect2.jpg',
  105. clickBig: false,
  106. // zoom: 2, // 超过2级就显示
  107. // maxZoom: 5,
  108. remark: {
  109. fontSize: 24,
  110. color: 'green',
  111. offset: [0, 0],
  112. },
  113. zIndex: 2
  114. }
  115. points = new CTMapOl.cesiumComponent.Points(options);
  116. points.addTo({ viewer: viewer })
  117. }
  118. // initData2()
  119. </script>
  120. <style>
  121. /*地图*/
  122. .mapDIV {
  123. height: 100vh;
  124. width: 100vw;
  125. z-index: 1;
  126. }
  127. .add-switch {
  128. position: absolute;
  129. right: 30px;
  130. height: 68px;
  131. width: 30px;
  132. bottom: 112px;
  133. background: #FFFFFF 100%;
  134. color: #172537;
  135. border-radius: 4px;
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. z-index: 2;
  140. }
  141. .add-s-block {
  142. height: 20px;
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. width: 100%;
  147. line-height: 20px;
  148. font-size: 12px;
  149. margin-bottom: 2px;
  150. color: #172537;
  151. }
  152. .add-zoom {
  153. width: 20px;
  154. height: 20px;
  155. background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
  156. background-size: 100% 100%;
  157. cursor: pointer;
  158. }
  159. .sub-zoom {
  160. width: 20px;
  161. height: 20px;
  162. background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
  163. background-size: 100% 100%;
  164. cursor: pointer;
  165. }
  166. .add-zoom-out {
  167. width: 20px;
  168. height: 20px;
  169. background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
  170. background-size: 100% 100%;
  171. }
  172. .sub-zoom-out {
  173. width: 20px;
  174. height: 20px;
  175. background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
  176. background-size: 100% 100%;
  177. }
  178. .add-s-block.btn-click {
  179. cursor: pointer;
  180. }
  181. .input-card {
  182. position: absolute;
  183. right: 15px;
  184. bottom: 15px;
  185. z-index: 999;
  186. }
  187. </style>
  188. </html>