perf(图表): 在想地图复用底图

This commit is contained in:
wisonic 2024-10-24 16:20:40 +08:00
parent 1e371bccdc
commit 19a97196ac
2 changed files with 48 additions and 22 deletions

View File

@ -96,18 +96,31 @@ export class FlowMap extends L7ChartView<Scene, L7Config> {
}
const mapKey = await this.getMapKey()
// 底层
const scene = new Scene({
id: container,
logoVisible: false,
map: new GaodeMap({
token: mapKey?.key ?? undefined,
style: mapStyle,
pitch: misc.mapPitch,
center,
zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5,
showLabel: !(basicStyle.showLabel === false)
const chartObj = drawOption.chartObj as unknown as L7Wrapper<L7Config, Scene>
let scene = chartObj?.getScene()
if (!scene) {
scene = new Scene({
id: container,
logoVisible: false,
map: new GaodeMap({
token: mapKey?.key ?? undefined,
style: mapStyle,
pitch: misc.mapPitch,
center,
zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5,
showLabel: !(basicStyle.showLabel === false)
})
})
})
} else {
if (scene.getLayers()?.length) {
await scene.removeAllLayer()
scene.setCenter(center)
scene.setPitch(misc.mapPitch)
scene.setZoom(basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5)
scene.setMapStyle(mapStyle)
scene.map.showLabel = !(basicStyle.showLabel === false)
}
}
mapRendering(container)
scene.once('loaded', () => {
mapRendered(container)

View File

@ -77,18 +77,31 @@ export class HeatMap extends L7ChartView<Scene, L7Config> {
}
const mapKey = await this.getMapKey()
// 底层
const scene = new Scene({
id: container,
logoVisible: false,
map: new GaodeMap({
token: mapKey?.key ?? undefined,
style: mapStyle,
pitch: miscStyle.mapPitch,
center,
zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5,
showLabel: !(basicStyle.showLabel === false)
const chartObj = drawOption.chartObj as unknown as L7Wrapper<L7Config, Scene>
let scene = chartObj?.getScene()
if (!scene) {
scene = new Scene({
id: container,
logoVisible: false,
map: new GaodeMap({
token: mapKey?.key ?? undefined,
style: mapStyle,
pitch: miscStyle.mapPitch,
center,
zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5,
showLabel: !(basicStyle.showLabel === false)
})
})
})
} else {
if (scene.getLayers()?.length) {
await scene.removeAllLayer()
scene.setCenter(center)
scene.setPitch(miscStyle.mapPitch)
scene.setZoom(basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5)
scene.setMapStyle(mapStyle)
scene.map.showLabel = !(basicStyle.showLabel === false)
}
}
mapRendering(container)
scene.once('loaded', () => {
mapRendered(container)