HightLight.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. <script src="../assets/dataJson/hebei.js"></script>
  12. <script src="../assets/dataJson/aomen.js"></script>
  13. </head>
  14. <body style="margin: 0; padding: 0;">
  15. <div id="map" style="height: 100vh; width: 100vw;"></div>
  16. <div class="input-card">
  17. <div class="input-item">
  18. <button class="btn" id="show" onclick="show()">显示</button>
  19. </div>
  20. <div class="input-item">
  21. <button class="btn" id="hide" onclick="hide()">隐藏</button>
  22. </div>
  23. <div class="input-item">
  24. <button class="btn" id="remove" onclick="remove()">移除</button>
  25. </div>
  26. <div class="input-item">
  27. <button class="btn" id="setOption" onclick="setOption()">修改配置</button>
  28. </div>
  29. </div>
  30. </body>
  31. <script>
  32. let map = new CTMapOl.cesiumComponent.ThrdimeInitMap({
  33. domId: 'map',
  34. center: [-87.14045498433224, 44.604935926720024],
  35. zoom: 5
  36. })
  37. let viewer = map._viewer;
  38. map.on('click', e => {
  39. console.log(123, e)
  40. })
  41. function show() {
  42. highlight.show();
  43. }
  44. function hide() {
  45. console.log('highlight', highlight)
  46. highlight.hide();
  47. }
  48. function remove() {
  49. highlight.remove();
  50. }
  51. function setOption() {
  52. let testpos1=aomenpos
  53. let loops=testpos1.split("|");
  54. let pos=[]
  55. for(let i=0;i<loops.length;i++)
  56. {
  57. let temp=loops[i].split(";");
  58. for(let j=0;j<temp.length;j++)
  59. {
  60. let tt=temp[j].split(",");
  61. temp[j]=[Number(tt[0]),Number(tt[1])]
  62. }
  63. pos.push([temp])
  64. }
  65. console.log(pos)
  66. highlight.setOption({
  67. color: 'pink',
  68. opacity: 0.3,
  69. positions: pos,
  70. outline: {
  71. color: 'gray',
  72. weight: 5
  73. }
  74. });
  75. }
  76. var highlight;
  77. function initData() {
  78. let options = {
  79. color: 'red',
  80. opacity: 0.5,
  81. // positions: [
  82. // [116.453322, 39.920255],
  83. // [116.460703, 39.897555],
  84. // [116.452292, 39.892353],
  85. // [116.439846, 39.891365],
  86. // [116.453322, 39.920255]
  87. // ],
  88. outline: {
  89. color: 'orange',
  90. weight: 5
  91. },
  92. keyword: '河北省'
  93. }
  94. highlight = new CTMapOl.cesiumComponent.Highlight(viewer, options);
  95. }
  96. initData();
  97. function initPoint() {
  98. let options = {
  99. lng: 103.230695,
  100. lat: 35.624892,
  101. id: "123",
  102. imgPath: '../assets/image/rect.jpg',
  103. iconSize: [50, 50],
  104. offset: [25, 30],
  105. clickBig: false,
  106. clickIcon: '../assets/image/rect2.jpg',
  107. zIndex: 1,
  108. }
  109. let p = new CTMapOl.cesiumComponent.Point(viewer, options);
  110. }
  111. initPoint();
  112. </script>
  113. <style>
  114. /*地图*/
  115. .mapDIV {
  116. height: 100vh;
  117. width: 100vw;
  118. z-index: 1;
  119. }
  120. .add-switch {
  121. position: absolute;
  122. right: 30px;
  123. height: 68px;
  124. width: 30px;
  125. bottom: 112px;
  126. background: #FFFFFF 100%;
  127. color: #172537;
  128. border-radius: 4px;
  129. display: flex;
  130. flex-direction: column;
  131. align-items: center;
  132. z-index: 2;
  133. }
  134. .add-s-block {
  135. height: 20px;
  136. display: flex;
  137. align-items: center;
  138. justify-content: center;
  139. width: 100%;
  140. line-height: 20px;
  141. font-size: 12px;
  142. margin-bottom: 2px;
  143. color: #172537;
  144. }
  145. .add-zoom {
  146. width: 20px;
  147. height: 20px;
  148. background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
  149. background-size: 100% 100%;
  150. cursor: pointer;
  151. }
  152. .sub-zoom {
  153. width: 20px;
  154. height: 20px;
  155. background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
  156. background-size: 100% 100%;
  157. cursor: pointer;
  158. }
  159. .add-zoom-out {
  160. width: 20px;
  161. height: 20px;
  162. background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
  163. background-size: 100% 100%;
  164. }
  165. .sub-zoom-out {
  166. width: 20px;
  167. height: 20px;
  168. background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
  169. background-size: 100% 100%;
  170. }
  171. .add-s-block.btn-click {
  172. cursor: pointer;
  173. }
  174. .input-card {
  175. position: absolute;
  176. right: 15px;
  177. bottom: 15px;
  178. z-index: 999;
  179. }
  180. </style>
  181. </html>