feat: 流向地图使用自定义key
This commit is contained in:
parent
1851cd7509
commit
99f07f2c6e
@ -5,11 +5,11 @@
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "SET NODE_OPTIONS=--openssl-legacy-provider &&vue-cli-service build",
|
||||
"build": "vue-cli-service build",
|
||||
"serves": "node --max_old_space_size=4096 node_modules/@vue/cli-service/bin/vue-cli-service.js build",
|
||||
"build:prod": "vue-cli-service build",
|
||||
"build:stage": "vue-cli-service build --mode staging",
|
||||
"dll": "SET NODE_OPTIONS=--openssl-legacy-provider && webpack -p --progress --config ./webpack.dll.conf.js",
|
||||
"dll": "webpack -p --progress --config ./webpack.dll.conf.js",
|
||||
"preview": "node build/index.js --preview",
|
||||
"lint": "eslint --ext .js,.vue src --fix",
|
||||
"lint-staged": "lint-staged",
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { Scene, LineLayer } from '@antv/l7'
|
||||
import { GaodeMap } from '@antv/l7-maps'
|
||||
import { getLanguage } from '@/lang'
|
||||
import { queryMapKey } from '@/api/map/map'
|
||||
|
||||
export function baseFlowMapOption(chartDom, chartId, chart, action) {
|
||||
export async function baseFlowMapOption(chartDom, chartId, chart, action) {
|
||||
const xAxis = JSON.parse(chart.xaxis)
|
||||
const xAxisExt = JSON.parse(chart.xaxisExt)
|
||||
let customAttr
|
||||
@ -20,9 +21,11 @@ export function baseFlowMapOption(chartDom, chartId, chart, action) {
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
const key = await getMapKey()
|
||||
chartDom = new Scene({
|
||||
id: chartId,
|
||||
map: new GaodeMap({
|
||||
token: key ?? undefined,
|
||||
lang: lang,
|
||||
pitch: size.mapPitch,
|
||||
style: mapStyle
|
||||
@ -85,3 +88,11 @@ export function baseFlowMapOption(chartDom, chartId, chart, action) {
|
||||
})
|
||||
return chartDom
|
||||
}
|
||||
|
||||
const getMapKey = async() => {
|
||||
const key = 'online-map-key'
|
||||
if (!localStorage.getItem(key)) {
|
||||
await queryMapKey().then(res => localStorage.setItem(key, res.data))
|
||||
}
|
||||
return localStorage.getItem(key)
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ export default {
|
||||
})
|
||||
window.addEventListener('resize', this.calcHeightDelay)
|
||||
},
|
||||
drawView() {
|
||||
async drawView() {
|
||||
const chart = JSON.parse(JSON.stringify(this.chart))
|
||||
// type
|
||||
// if (chart.data) {
|
||||
@ -298,7 +298,7 @@ export default {
|
||||
} else if (chart.type === 'chart-mix') {
|
||||
this.myChart = baseMixOptionAntV(this.myChart, this.chartId, chart, this.antVAction)
|
||||
} else if (chart.type === 'flow-map') {
|
||||
this.myChart = baseFlowMapOption(this.myChart, this.chartId, chart, this.antVAction)
|
||||
this.myChart = await baseFlowMapOption(this.myChart, this.chartId, chart, this.antVAction)
|
||||
} else if (chart.type === 'bidirectional-bar') {
|
||||
this.myChart = baseBidirectionalBarOptionAntV(this.myChart, this.chartId, chart, this.antVAction)
|
||||
} else {
|
||||
@ -338,7 +338,6 @@ export default {
|
||||
}
|
||||
this.setBackGroundBorder()
|
||||
},
|
||||
|
||||
antVAction(param) {
|
||||
switch (this.chart.type) {
|
||||
case 'treemap':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user