diff --git a/package.json b/package.json
index 740a0374..460163fc 100644
--- a/package.json
+++ b/package.json
@@ -56,7 +56,7 @@
"@zouyaoji/heatmap.js": "^2.0.8",
"compare-versions": "^6.1.0",
"echarts": "^5.4.3",
- "kdbush": "^3.0.0",
+ "kdbush": "^4.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lodash-unified": "^1.0.3",
diff --git a/packages/shared/src/PrimitiveCluster.ts b/packages/shared/src/PrimitiveCluster.ts
index 30af5ea8..dda6af85 100644
--- a/packages/shared/src/PrimitiveCluster.ts
+++ b/packages/shared/src/PrimitiveCluster.ts
@@ -3,8 +3,8 @@
* @Date: 2023-05-26 13:30:22
* @Description: Do not edit
* @LastEditors: zouyaoji 370681295@qq.com
- * @LastEditTime: 2023-07-28 14:58:36
- * @FilePath: \vue-cesium@next\packages\shared\src\PrimitiveCluster.ts
+ * @LastEditTime: 2024-04-02 00:43:38
+ * @FilePath: \vue-cesium\packages\shared\src\PrimitiveCluster.ts
*/
import { defaultValue } from '@vue-cesium/utils/util'
import KDBush from 'kdbush'
@@ -633,7 +633,11 @@ function createDeclutterCallback(entityCluster) {
let collection
let collectionIndex
- const index = new KDBush(points, getX, getY, 64, Int32Array)
+ const index = new KDBush(points.length, 64, Int32Array)
+ for (let i = 0; i < points.length; i++) {
+ index.add(points[i].coord.x, points[i].coord.y)
+ }
+ index.finish()
if (currentHeight < previousHeight) {
length = clusters.length
diff --git a/packages/vue-cesium/package.json b/packages/vue-cesium/package.json
index af2a4584..5fd4fee0 100644
--- a/packages/vue-cesium/package.json
+++ b/packages/vue-cesium/package.json
@@ -56,7 +56,7 @@
"@zouyaoji/heatmap.js": "^2.0.8",
"compare-versions": "^6.1.0",
"echarts": "^5.4.3",
- "kdbush": "^3.0.0",
+ "kdbush": "^4.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"lodash-unified": "^1.0.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e550a120..542757e6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -45,8 +45,8 @@ importers:
specifier: ^5.4.3
version: 5.4.3
kdbush:
- specifier: ^3.0.0
- version: 3.0.0
+ specifier: ^4.0.2
+ version: 4.0.2
lodash:
specifier: ^4.17.21
version: 4.17.21
@@ -4568,6 +4568,7 @@ packages:
/@vue/compiler-core@3.3.6:
resolution: {integrity: sha512-2JNjemwaNwf+MkkatATVZi7oAH1Hx0B04DdPH3ZoZ8vKC1xZVP7nl4HIsk8XYd3r+/52sqqoz9TWzYc3yE9dqA==}
+ requiresBuild: true
dependencies:
'@babel/parser': 7.23.0
'@vue/shared': 3.3.6
@@ -12412,6 +12413,10 @@ packages:
resolution: {integrity: sha512-hRkd6/XW4HTsA9vjVpY9tuXJYLSlelnkTmVFu4M9/7MIYQtFcHpbugAU7UbOfjOiVSVYl2fqgBuJ32JUmRo5Ew==}
dev: false
+ /kdbush@4.0.2:
+ resolution: {integrity: sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA==}
+ dev: false
+
/keyv@3.1.0:
resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==}
dependencies:
diff --git a/website/docs/zh-CN/primitives/vc-primitive-cluster.md b/website/docs/zh-CN/primitives/vc-primitive-cluster.md
index 2c43c91f..df98cd6c 100644
--- a/website/docs/zh-CN/primitives/vc-primitive-cluster.md
+++ b/website/docs/zh-CN/primitives/vc-primitive-cluster.md
@@ -18,6 +18,7 @@
:enabled="enabled"
v-if="billboards.length"
:billboards="billboards"
+ :labels="labels"
:minimum-cluster-size="minimumClusterSize"
@cluster-event="onClusterEvent"
@click="onClicked"
@@ -26,7 +27,7 @@
-
+
@@ -53,6 +54,7 @@
const show = ref(true)
const enabled = ref(true)
const billboards = ref([])
+ const labels = ref([])
const primitiveClusterRef = ref(null)
const indicatorRef = ref(null)
const minimumClusterSize = ref(3)
@@ -80,12 +82,27 @@
const feature = features[i]
const coordinates = feature.geometry.coordinates
+ labels.value.push({
+ show: true,
+ scale: 1,
+ showBackground: true,
+ backgroundColor: Cesium.Color.fromCssColorString('#000000').withAlpha(0.8),
+ verticalOrigin: 1,
+ horizontalOrigin: 0,
+ pixelOffset: new Cesium.Cartesian2(0, -10),
+ font: '16px sans-serif',
+ position: [coordinates[0], coordinates[1]],
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
+ distanceDisplayCondition: [0, Number.POSITIVE_INFINITY],
+ text: 'label'
+ })
+
billboards.value.push({
image: 'https://zouyaoji.top/vue-cesium/images/mark-icon.png',
width: 32,
height: 32,
position: [coordinates[0], coordinates[1]],
- onClick: (e) => {
+ onClick: e => {
console.log(e)
}
})
@@ -166,6 +183,7 @@
onClicked,
onMouseOver,
onViewerReady,
+ labels,
billboards,
pickEvt,
indicatorRef,