From 977519d7d8202305f3c763d20eec1b0664755d4c Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 22 Jul 2024 15:41:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=B8=96=E7=95=8C?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E6=A0=87=E7=AD=BE=E6=9C=AA=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=20#9890?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/package.json | 1 + .../chart/components/js/panel/common/common_antv.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/package.json b/core/core-frontend/package.json index 90a12fe687..dc6233168c 100644 --- a/core/core-frontend/package.json +++ b/core/core-frontend/package.json @@ -21,6 +21,7 @@ "@codemirror/lang-sql": "^6.4.0", "@npkg/tinymce-plugins": "^0.0.7", "@tinymce/tinymce-vue": "^5.1.0", + "@turf/centroid": "^7.0.0", "@videojs-player/vue": "^1.0.0", "@vueuse/core": "^9.13.0", "ace-builds": "^1.15.3", diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 5bc9e3f96f..050b56e31c 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -28,6 +28,7 @@ import { DOM } from '@antv/l7-utils' import { Scene } from '@antv/l7-scene' import { type IZoomControlOption } from '@antv/l7-component' import { PositionType } from '@antv/l7-core' +import { centroid } from '@turf/centroid' export function getPadding(chart: Chart): number[] { if (chart.drill) { @@ -890,8 +891,13 @@ export function configL7Tooltip(chart: Chart): TooltipOptions { export function handleGeoJson(geoJson: FeatureCollection, nameMapping?: Record) { geoJson.features.forEach(item => { - if (!item.properties['centroid'] && item.properties['center']) { - item.properties['centroid'] = item.properties['center'] + if (!item.properties['centroid']) { + if (item.properties['center']) { + item.properties['centroid'] = item.properties['center'] + } else { + const tmp = centroid(item.geometry) + item.properties['centroid'] = tmp.geometry.coordinates + } } let name = item.properties['name'] if (nameMapping?.[name]) {