Skip to content

Commit ed948ef

Browse files
ulleodataeaseShu
authored andcommitted
feat(图表): 支持腾讯地图
修复缩放按钮中刷新不生效问题
1 parent 31bbe67 commit ed948ef

File tree

4 files changed

+50
-10
lines changed

4 files changed

+50
-10
lines changed

core/core-frontend/src/views/chart/components/js/panel/charts/map/bubble-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class BubbleMap extends L7PlotChartView<ChoroplethOptions, Choropleth> {
171171
}
172172
dotLayer.addToScene(view.scene)
173173
dotLayer.once('add', () => {
174-
mapRendered(container)
174+
mapRendered(container, scene)
175175
})
176176
view.scene.map['keyboard'].disable()
177177
dotLayer.on('dotLayer:click', (ev: MapMouseEvent) => {

core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
109109
this.startAndEndNameConfig(chart, xAxis, xAxisExt, misc, configList)
110110
this.pointConfig(chart, xAxis, xAxisExt, misc, configList)
111111
configList[0].once('inited', () => {
112-
mapRendered(container)
112+
mapRendered(container, scene)
113113
})
114114
return new L7Wrapper(scene, configList)
115115
}

core/core-frontend/src/views/chart/components/js/panel/charts/map/heat-map.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { DEFAULT_BASIC_STYLE } from '@/views/chart/components/editor/util/chart'
1414
import {
1515
getMapCenter,
1616
getMapScene,
17-
getMapStyle
17+
getMapStyle,
18+
mapRendered
1819
} from '@/views/chart/components/js/panel/common/common_antv'
1920
const { t } = useI18n()
2021

@@ -117,6 +118,10 @@ export class HeatMap extends L7ChartView<Scene, L7Config> {
117118
}
118119
})
119120

121+
config.once('inited', () => {
122+
mapRendered(container, scene)
123+
})
124+
120125
return new L7Wrapper(scene, config)
121126
}
122127

core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,13 +1173,27 @@ export class CustomZoom extends Zoom {
11731173
'l7-button-control',
11741174
container,
11751175
() => {
1176-
if (this.controlOption['bounds']) {
1177-
this.mapsService.fitBounds(this.controlOption['bounds'], { animate: true })
1176+
if (this.mapsService.map?.deMapProvider == 'qq') {
1177+
if (this.mapsService.map.deMapAutoFit) {
1178+
this.mapsService.setZoomAndCenter(this.mapsService.map.deMapAutoZoom, [
1179+
this.mapsService.map.deMapAutoLng,
1180+
this.mapsService.map.deMapAutoLat
1181+
])
1182+
} else {
1183+
this.mapsService.setZoomAndCenter(
1184+
this.controlOption['initZoom'],
1185+
this.controlOption['center']
1186+
)
1187+
}
11781188
} else {
1179-
this.mapsService.setZoomAndCenter(
1180-
this.controlOption['initZoom'],
1181-
this.controlOption['center']
1182-
)
1189+
if (this.controlOption['bounds']) {
1190+
this.mapsService.fitBounds(this.controlOption['bounds'], { animate: true })
1191+
} else {
1192+
this.mapsService.setZoomAndCenter(
1193+
this.controlOption['initZoom'],
1194+
this.controlOption['center']
1195+
)
1196+
}
11831197
}
11841198
}
11851199
)
@@ -1396,11 +1410,21 @@ export function mapRendering(dom: HTMLElement | string) {
13961410
dom.classList.add('de-map-rendering')
13971411
}
13981412

1399-
export function mapRendered(dom: HTMLElement | string) {
1413+
export function mapRendered(dom: HTMLElement | string, scene?: Scene) {
14001414
if (typeof dom === 'string') {
14011415
dom = document.getElementById(dom)
14021416
}
14031417
dom.classList.add('de-map-rendered')
1418+
1419+
if (scene?.map && scene.map.deMapProvider === 'qq') {
1420+
setTimeout(() => {
1421+
if (scene.map) {
1422+
scene.map.deMapAutoZoom = scene.map.getZoom()
1423+
scene.map.deMapAutoLng = scene.map.getCenter().getLng()
1424+
scene.map.deMapAutoLat = scene.map.getCenter().getLat()
1425+
}
1426+
}, 1000)
1427+
}
14041428
}
14051429

14061430
export function getMapCenter(basicStyle: ChartBasicStyle) {
@@ -1498,6 +1522,11 @@ export async function getMapScene(
14981522
}
14991523
if (basicStyle.autoFit === false) {
15001524
scene.setZoomAndCenter(basicStyle.zoomLevel, center)
1525+
if (mapKey.mapType === 'qq') {
1526+
scene.map.deMapAutoFit = false
1527+
scene.map.deMapZoom = basicStyle.zoomLevel
1528+
scene.map.deMapCenter = center
1529+
}
15011530
}
15021531
}
15031532
mapRendering(container)
@@ -1511,6 +1540,12 @@ export async function getMapScene(
15111540
//仅渲染:道路及底面(base) + 2d建筑物(building2d),以达到隐藏文字的效果
15121541
})
15131542
scene.setMapStyle(mapStyle)
1543+
1544+
scene.map.deMapProvider = 'qq'
1545+
scene.map.deMapAutoFit = !!basicStyle.autoFit
1546+
// scene.map.deMapAutoZoom = scene.map.getZoom()
1547+
// scene.map.deMapAutoLng = scene.map.getCenter().getLng()
1548+
// scene.map.deMapAutoLat = scene.map.getCenter().getLat()
15141549
}
15151550
// 去除天地图自己的缩放按钮
15161551
if (mapKey.mapType === 'tianditu') {

0 commit comments

Comments
 (0)