MarkerCluster2.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <!-- Use correct character set. -->
  5. <meta charset="utf-8"/>
  6. <!-- Tell IE to use the latest, best version. -->
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  8. <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
  9. <meta
  10. name="viewport"
  11. content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
  12. />
  13. <title>Hello World!</title>
  14. <link rel="stylesheet" href="../../dist/index.css"/>
  15. <script src="../../dist/index.js"></script>
  16. <script src="../build/cesium/Cesium.js"></script>
  17. <link href="../build/cesium/Widgets/widgets.css" rel="stylesheet">
  18. <script src="https://unpkg.com/@turf/turf/turf.min.js"></script>
  19. <style>
  20. html,
  21. body,
  22. #cesiumContainer {
  23. width: 100%;
  24. height: 100%;
  25. margin: 0;
  26. padding: 0;
  27. overflow: hidden;
  28. }
  29. .box {
  30. position: fixed;
  31. left: 0;
  32. top: 0;
  33. z-index: 1000;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div id="cesiumContainer"></div>
  39. <div class="box">
  40. <button id="locationById">通过id定位</button>
  41. <button id="restore">取消选中</button>
  42. <button id="getViewMarkers">获取当前可视范围内该聚合实例中非聚合点数据</button>
  43. <button id="close">取消聚合</button>
  44. <button id="open">开启聚合</button>
  45. </div>
  46. <script src="../assets/dataJson/cluster.js"></script>
  47. <script>
  48. let map = new CTMapOl.cesiumComponent.ThrdimeInitMap({
  49. domId: 'cesiumContainer',
  50. center: [-87.14045498433224, 44.604935926720024],
  51. zoom: 3
  52. })
  53. let viewer = map._viewer;
  54. let option = {
  55. dataOptions: [
  56. {
  57. "icon": "../assets/image/circled.png",
  58. "iconSize": [
  59. 40,
  60. 40
  61. ],
  62. child: {
  63. "icon": "../assets/image/rect.jpg",
  64. "iconSize": [
  65. 20,
  66. 20
  67. ],
  68. "offset": [
  69. 0,
  70. 0
  71. ],
  72. },
  73. "offset": [
  74. 17,
  75. 17
  76. ],
  77. // "clickIcon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAD7VJREFUaEPNWwl0VdXV/va5LzMkgUAgQAIoYSqCQAKEMSkqogIWbBX8FacKUmtBtLW6HFqrrVbEuULhl1BlsAJSQBAEBBICMsgcAohgyhyGEBIyvHt21zn3zXnJey8kLs9aWVnrvn33Od/d++zp7ENooMEnT0YjonwgmHqDRCeA1V9LgBoD3NgxbQkA9XcaQAEYBSDegYrIHGrVqqwhlkb1yZRPH0lEGI0DMBqMvgCFAwzAMQ0zQASo/2qoxx4/ezyoBGErwItRxfOoZYez9bXOegHMZw8NhqCnwXQrCDYNwi8gn2U7wTrpfVFZH8QO4lWQ/HdK7LjxWoFfE2A+dyQLkH8GY6DfhfhK0BegU9rqvxq+GlD9A+QA9Dw1T/26rsDrBJjPHUiCNKaBMNZHJ73WwSVnwWfygUuF4MungSvnwFXlgFlu0RmRoLBIoFFzUGxLID4Z1KILqHFi7XgY8yHMqdS866lQgYcMmM8WDAfkfABxrv3nocJ8sRB8fAvkD9uA0ouhrseij24CkZIOapcBim9TE49ikBhLiZ1WhjJJSID5zP6pYLwOQFh71GGAiMAXjkHu+gx89lAo8wekpcROED1Gg5q285rPsQUkSPyeWnSZFpCRh1kJSMuHD0eg0dUZIDHetc8cbym1lXuXggt3BORzLQSU3Bui20hQbAsPK+/44IKycTliAqWmVgSaI6CE+dTO5oBtKYAML2ZSQu79HPLwekCageapn9+FAZGaBXHDnYCwlMxj5AH2UZTU61xtk9UK2JJs2XowW2CdKlxVCnPz7HpX32C/CiV2hNH/YSAsxsevUx6uRGfVJunaAZ/8dg6A8Z4L4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cE2CXxzX8eAtBTYL4VRLYa7yVVu9Xic2/J/7UeFdqtAuEN6v/CNbcE1gtgF/Atr7SArBoLptGAuqjFrr4RiyaQCF2iqASwFSQWg+U8GvDST+uill/jtf2laFSoNkbZG3BcxSO0BKMxCNZVPOYSEJWA2bqKp/5I7EAEcijtpQbJL/8Hb/5n060RxqoAAAAASUVORK5CYII=",
  78. "clickBig": true,
  79. "id": "10001",
  80. "lnglat": [
  81. -88.90153665861239, 50.745409647716
  82. ]
  83. },
  84. {
  85. "icon": "../assets/image/rect.jpg",
  86. "iconSize": [
  87. 34,
  88. 34
  89. ],
  90. "offset": [
  91. 17,
  92. 17
  93. ],
  94. "clickIcon": "../assets/image/rect2.jpg",
  95. "clickBig": false,
  96. "id": "2680550",
  97. "lnglat": [
  98. -88.90153665861239, 51.745409647716
  99. ]
  100. }
  101. ],
  102. MarkerClusterOptions: {
  103. "clusterId": "layer-camera",
  104. "gridSize": 80,
  105. // "offsetBottom": true,
  106. "sourceType": "layer-camera",
  107. // "clickBig": false,
  108. "maxZoom": 10,
  109. "zIndex": 60,
  110. "styles": [
  111. {
  112. "url": "../assets/image/rect2.jpg",
  113. "size": [
  114. 48,
  115. 48
  116. ],
  117. "textColor": "white",
  118. "offset": [
  119. 24,
  120. 24
  121. ],
  122. "textSize": 14,
  123. "textOffset": [
  124. 0,
  125. 8
  126. ]
  127. }
  128. ]
  129. }
  130. }
  131. let cluster = new CTMapOl.cesiumComponent.MarkerCluster(viewer, option) // 圆
  132. cluster.on('markerclick', e => {
  133. console.log('markerclick', e)
  134. })
  135. document.getElementById('locationById').onclick = e => {
  136. cluster.locationById({id: 'marker2'})
  137. }
  138. document.getElementById('getViewMarkers').onclick = e => {
  139. console.log('当前可视范围内该聚合实例中非聚合点数据', getViewMarkers())
  140. }
  141. document.getElementById('open').onclick = e => {
  142. cluster.setEnable(true)
  143. cluster2.setEnable(true)
  144. }
  145. document.getElementById('close').onclick = e => {
  146. cluster.setEnable(false)
  147. cluster2.setEnable(false)
  148. }
  149. document.getElementById('restore').onclick = e => {
  150. cluster.restore()
  151. }
  152. </script>
  153. </body>
  154. </html>