Skip to content

Commit 80ea788

Browse files
committed
Merge branch 'dev' of github.com:zouyaoji/vue-cesium into dev
2 parents 82a1022 + 9d33ff8 commit 80ea788

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@zouyaoji/heatmap.js": "^2.0.8",
5757
"compare-versions": "^6.1.0",
5858
"echarts": "^5.4.3",
59-
"kdbush": "^3.0.0",
59+
"kdbush": "^4.0.2",
6060
"lodash": "^4.17.21",
6161
"lodash-es": "^4.17.21",
6262
"lodash-unified": "^1.0.3",

packages/shared/src/PrimitiveCluster.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* @Date: 2023-05-26 13:30:22
44
* @Description: Do not edit
55
* @LastEditors: zouyaoji 370681295@qq.com
6-
* @LastEditTime: 2023-07-28 14:58:36
7-
* @FilePath: \vue-cesium@next\packages\shared\src\PrimitiveCluster.ts
6+
* @LastEditTime: 2024-04-02 00:43:38
7+
* @FilePath: \vue-cesium\packages\shared\src\PrimitiveCluster.ts
88
*/
99
import { defaultValue } from '@vue-cesium/utils/util'
1010
import KDBush from 'kdbush'
@@ -633,7 +633,11 @@ function createDeclutterCallback(entityCluster) {
633633
let collection
634634
let collectionIndex
635635

636-
const index = new KDBush(points, getX, getY, 64, Int32Array)
636+
const index = new KDBush(points.length, 64, Int32Array)
637+
for (let i = 0; i < points.length; i++) {
638+
index.add(points[i].coord.x, points[i].coord.y)
639+
}
640+
index.finish()
637641

638642
if (currentHeight < previousHeight) {
639643
length = clusters.length

packages/vue-cesium/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@zouyaoji/heatmap.js": "^2.0.8",
5757
"compare-versions": "^6.1.0",
5858
"echarts": "^5.4.3",
59-
"kdbush": "^3.0.0",
59+
"kdbush": "^4.0.2",
6060
"lodash": "^4.17.21",
6161
"lodash-es": "^4.17.21",
6262
"lodash-unified": "^1.0.3",

pnpm-lock.yaml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/docs/zh-CN/primitives/vc-primitive-cluster.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
:enabled="enabled"
1919
v-if="billboards.length"
2020
:billboards="billboards"
21+
:labels="labels"
2122
:minimum-cluster-size="minimumClusterSize"
2223
@cluster-event="onClusterEvent"
2324
@click="onClicked"
@@ -26,7 +27,7 @@
2627
</vc-collection-primitive>
2728

2829
<vc-selection-indicator ref="indicatorRef" @pickEvt="pickEvt"></vc-selection-indicator>
29-
<!-- 注记层 -->
30+
<!-- 注记层 -->
3031
<vc-layer-imagery :sort-order="20">
3132
<vc-imagery-provider-tianditu map-style="cva_c" token="436ce7e50d27eede2f2929307e6b33c0"></vc-imagery-provider-tianditu>
3233
</vc-layer-imagery>
@@ -53,6 +54,7 @@
5354
const show = ref(true)
5455
const enabled = ref(true)
5556
const billboards = ref([])
57+
const labels = ref([])
5658
const primitiveClusterRef = ref(null)
5759
const indicatorRef = ref(null)
5860
const minimumClusterSize = ref(3)
@@ -80,12 +82,27 @@
8082
const feature = features[i]
8183
const coordinates = feature.geometry.coordinates
8284
85+
labels.value.push({
86+
show: true,
87+
scale: 1,
88+
showBackground: true,
89+
backgroundColor: Cesium.Color.fromCssColorString('#000000').withAlpha(0.8),
90+
verticalOrigin: 1,
91+
horizontalOrigin: 0,
92+
pixelOffset: new Cesium.Cartesian2(0, -10),
93+
font: '16px sans-serif',
94+
position: [coordinates[0], coordinates[1]],
95+
disableDepthTestDistance: Number.POSITIVE_INFINITY,
96+
distanceDisplayCondition: [0, Number.POSITIVE_INFINITY],
97+
text: 'label'
98+
})
99+
83100
billboards.value.push({
84101
image: 'https://zouyaoji.top/vue-cesium/images/mark-icon.png',
85102
width: 32,
86103
height: 32,
87104
position: [coordinates[0], coordinates[1]],
88-
onClick: (e) => {
105+
onClick: e => {
89106
console.log(e)
90107
}
91108
})
@@ -166,6 +183,7 @@
166183
onClicked,
167184
onMouseOver,
168185
onViewerReady,
186+
labels,
169187
billboards,
170188
pickEvt,
171189
indicatorRef,

0 commit comments

Comments
 (0)