首页地图+飞线 初版

首页地图+飞线 初版
This commit is contained in:
TimSpan 2024-08-14 11:27:03 +08:00
parent 5e3fa3c327
commit ec4f2ef216
5 changed files with 445 additions and 90 deletions

BIN
public/keji_border.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -0,0 +1,59 @@
export default [
{
name: '长沙市',
value: [112.94, 28.23],
},
{
name: '怀化市',
value: [110.0, 27.57],
},
{
name: '益阳市',
value: [112.36, 28.55],
},
{
name: '常德市',
value: [111.7, 29.03],
},
{
name: '岳阳市',
value: [113.13, 29.36],
},
{
name: '张家界市',
value: [110.48, 29.12],
},
{
name: '邵阳市',
value: [111.47, 27.24],
},
{
name: '娄底市',
value: [111.99, 27.7],
},
{
name: '湘潭市',
value: [112.95, 27.83],
},
{
name: '株洲市',
value: [113.13, 27.83],
},
{
name: '湘西土家族苗族自治州',
value: [109.67, 28.22],
},
{
name: '衡阳市',
value: [112.57, 26.89],
},
{
name: '永州市',
value: [111.61, 26.42],
},
{
name: '郴州市',
value: [113.02, 25.77],
},
]

83
src/utils/linesData.ts Normal file
View File

@ -0,0 +1,83 @@
export default [
{
// fromName: '怀化市',
// toName: '长沙市',
coords: [
[110.0, 27.57],
[112.94, 28.23]
]
},
{
coords: [
[112.36, 28.55], //益阳市
[112.94, 28.23]
]
},
{
coords: [
[111.7, 29.03], //常德市
[112.94, 28.23]
]
},
{
coords: [
[113.13, 29.36], //岳阳市
[112.94, 28.23]
]
},
{
coords: [
[110.48, 29.12], //张家界市
[112.94, 28.23]
]
},
{
coords: [
[111.47, 27.24], //邵阳市
[112.94, 28.23]
]
},
{
coords: [
[111.99, 27.7], //娄底市
[112.94, 28.23]
]
},
{
coords: [
[112.95, 27.83], //湘潭市
[112.94, 28.23]
]
},
{
coords: [
[113.13, 27.83], //株洲市
[112.94, 28.23]
]
},
{
coords: [
[109.67, 28.22], //湘西土家族苗族自治州
[112.94, 28.23]
]
},
{
coords: [
[112.57, 26.89], //衡阳市
[112.94, 28.23]
]
},
{
coords: [
[111.61, 26.42], //永州市
[112.94, 28.23]
]
},
{
coords: [
[113.02, 25.77], //郴州市
[112.94, 28.23]
]
}
]

View File

@ -177,6 +177,8 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import effectScatterData from '@/utils/effectScatterData'
import linesData from '@/utils/linesData'
import 'echarts-gl' import 'echarts-gl'
// @ts-ignore // @ts-ignore
import {getAreaCode} from './js/area' import {getAreaCode} from './js/area'
@ -184,6 +186,7 @@ import {JsonResult} from '@/axios'
import {Ref, ref, watch, onMounted, onBeforeMount, reactive, getCurrentInstance, nextTick} from 'vue' import {Ref, ref, watch, onMounted, onBeforeMount, reactive, getCurrentInstance, nextTick} from 'vue'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import api from '@/axios' import api from '@/axios'
import {fa} from 'element-plus/es/locale'
const {proxy} = getCurrentInstance() as any const {proxy} = getCurrentInstance() as any
const day = proxy.day const day = proxy.day
onMounted(() => { onMounted(() => {
@ -464,27 +467,7 @@ const get3 = (city: any, district: any, town: any) => {
} }
}) })
} }
// const convertData = (data) => {
// var res = []
// for (var i = 0; i < data.length; i++) {
// var dataItem = data[i]
// var fromCoord = chinaGeoCoordMap[dataItem[0].name]
// var toCoord = [116.4551, 40.2539]
// if (fromCoord && toCoord) {
// res.push([
// {
// coord: fromCoord,
// value: dataItem[0].value,
// },
// {
// coord: toCoord,
// },
// ])
// }
// }
// return res
// }
var mapJson = ''
const flattenTree = (treeData: any) => { const flattenTree = (treeData: any) => {
const result: any[] = [] const result: any[] = []
function traverse(node: any) { function traverse(node: any) {
@ -501,10 +484,10 @@ const flattenTree = (treeData: any) => {
return result return result
} }
const maptitle = ref('') const maptitle = ref('')
const initMapdt = (data: any, podat: any, nameb: any) => { const initMapdt = (data: any, podat: any, name: any) => {
console.log('initMapdt(name)_________', name)
var tree4data = flattenTree(JSON.parse(localStorage.getItem('tree4data'))) var tree4data = flattenTree(JSON.parse(localStorage.getItem('tree4data')))
// maptitle.value = tree4data.find(element => element.code == JSON.parse(data)['name'])['title']; maptitle.value = name
maptitle.value = nameb
localStorage.setItem('nowCode', JSON.parse(data)['name']) localStorage.setItem('nowCode', JSON.parse(data)['name'])
const myChart = echarts.init(document.getElementById('myMap')) const myChart = echarts.init(document.getElementById('myMap'))
// myChart.showLoading(); // myChart.showLoading();
@ -516,92 +499,319 @@ const initMapdt = (data: any, podat: any, nameb: any) => {
var option = { var option = {
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
textStyle: {fontSize: '14', color: '#fff', fontFamily: 'Arial'}, // textStyle: {fontSize: '14', color: '#fff', fontFamily: 'Arial'},
backgroundColor: '#092b6a', // backgroundColor: '#092b6a',
formatter: (params: any) => { // 线lines lines3D tooltip tooltip
let datat = podat // tooltip formatter
let itemWithId2 = datat.children.find((item: any) => item.grope === params.name) formatter: function (params: any) {
if (itemWithId2 == null || itemWithId2 == undefined) { // console.log(111, params)
return '<br /> 报警:' + '0' + '<br /> 警情:' + '0' + ' <br /> AI预警:' + '0' //
} else { if (params.seriesType === 'map') {
return '<br /> 报警:' + itemWithId2.alarmCount + '<br /> 警情:' + itemWithId2.caseCount + ' <br /> AI预警:' + itemWithId2.aiCount console.log("params.seriesType === 'map'")
// tooltip
let datat = podat
let itemWithId2 = datat.children.find((item: any) => item.grope === params.name)
if (!itemWithId2) {
return `
<div style="
background: url('/keji_border.png') no-repeat center center;
background-size: contain;
height: 150px;
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
padding: 10px;
box-sizing: border-box;
">
报警: 0<br />
警情: 0<br />
AI预警: 0
</div>
`
} else {
return `
<div style="
background: url('/keji_border.png') no-repeat center center;
background-size: contain;
height: 150px;
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
padding: 10px;
box-sizing: border-box;
">
报警: ${itemWithId2.alarmCount}<br />
警情: ${itemWithId2.caseCount}<br />
AI预警: ${itemWithId2.aiCount}
</div>
`
}
} else if (params.seriesType === 'lines') {
// 线tooltip
return `线路: ${params.data.fromName}${params.data.toName}`
} else if (params.seriesType === 'effectScatter') {
// 线
return `终点: ${params.name}`
} }
//
return ''
} }
}, },
series: [ geo: [
{ {
type: 'map3D',
name: '地图',
selectedMode: 'single', //
regionHeight: 1, //
map: 'myMap', map: 'myMap',
viewControl: { aspectScale: 1,
distance: 168, // zoom: 0.9,
alpha: 180, // layoutCenter: ['50%', '50%'],
rotateSensitivity: 0 layoutSize: '100%',
}, show: true,
roam: false,
label: { label: {
show: true, // show: true, //
color: '#fff', // color: '#fff'
fontSize: 15, //
fontWeight: 'bold' //
}, },
itemStyle: { itemStyle: {
color: '#0A3E77', // areaColor: {
borderWidth: 1, // 线wdith type: 'linear',
borderColor: '#a4d8f0', // 线 x: 1200,
opacity: 0.9 y: 0,
x2: 0,
y2: 0,
colorStops: [
{
offset: 0,
color: 'rgba(3,27,78,0.75)'
},
{
offset: 1,
color: 'rgba(58,149,253,0.75)'
}
],
global: true // false
},
borderColor: '#c0f3fb',
borderWidth: 0.8
}, },
emphasis: { emphasis: {
label: {
show: true, //
textStyle: {
color: '#fff' //
}
},
itemStyle: { itemStyle: {
color: '#3a69c1', // show: false,
borderWidth: 10, // 线wdith
borderColor: '#6BECF5' // 线
}
},
light: {
main: {
color: '#fff', color: '#fff',
intensity: 1, areaColor: 'rgba(0,254,233,0.6)'
shadow: true, // areaColor: '#3a69c1'
shadowQuality: 'high', // areaColor: '#07315e'
alpha: 25, //
beta: 20
}, },
ambient: { label: {
color: '#fff', show: true,
intensity: 0.6 color: '#fff'
}
}
},
//
{
type: 'map',
map: 'myMap',
zlevel: -1,
aspectScale: 1,
zoom: 0.9,
layoutCenter: ['50%', '51%'],
layoutSize: '100%',
roam: false,
silent: true,
itemStyle: {
borderWidth: 1,
borderColor: 'rgba(58,149,253,0.8)',
shadowColor: 'rgba(172, 122, 255,0.5)',
shadowOffsetY: 5,
shadowBlur: 15,
areaColor: 'rgba(5,21,35,0.1)'
}
},
{
type: 'map',
map: 'myMap',
zlevel: -2,
aspectScale: 1,
zoom: 0.9,
layoutCenter: ['50%', '52%'],
layoutSize: '100%',
roam: false,
silent: true,
itemStyle: {
borderWidth: 1,
borderColor: 'rgba(58,149,253,0.6)',
shadowColor: 'rgba(65, 214, 255,0.6)',
shadowOffsetY: 5,
shadowBlur: 15,
areaColor: 'rgba(5,21,35,0.1)'
}
},
{
type: 'map',
map: 'myMap',
zlevel: -3,
aspectScale: 1,
zoom: 0.9,
layoutCenter: ['50%', '53%'],
layoutSize: '100%',
roam: false,
silent: true,
itemStyle: {
borderWidth: 1,
borderColor: 'rgba(58,149,253,0.4)',
shadowColor: 'rgba(29, 111, 165,1)',
shadowOffsetY: 15,
shadowBlur: 10,
areaColor: 'rgba(5,21,35,0.1)'
}
},
{
type: 'map',
map: 'myMap',
zlevel: -4,
aspectScale: 1,
zoom: 0.9,
layoutCenter: ['50%', '54%'],
layoutSize: '100%',
roam: false,
silent: true,
itemStyle: {
borderWidth: 5,
borderColor: 'rgba(5,9,57,0.8)',
shadowColor: 'rgba(29, 111, 165,0.8)',
shadowOffsetY: 15,
shadowBlur: 10,
areaColor: 'rgba(5,21,35,0.1)'
}
}
],
series: [
{
type: 'map',
map: 'myMap',
geoIndex: 0, //geoIndex
tooltip: {
trigger: 'item',
backgroundColor: 'rgba(0,0,0,0)',
borderColor: 'rgba(0,0,0,0)',
extraCssText: 'box-shadow: 0 0 0 rgba(0, 0, 0, 0);',
textStyle: {fontSize: '16', color: '#fff'},
formatter: function (params: any) {
// tooltip
// console.log(222, params)
let datat = podat
let itemWithId2 = datat.children.find((item: any) => item.grope === params.name)
if (!itemWithId2) {
return `
<div style="
background: url('/keji_border.png') no-repeat center center;
background-size: contain;
height: 150px;
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
padding: 10px;
box-sizing: border-box;
">
报警: 0<br />
警情: 0<br />
AI预警: 0
</div>
`
} else {
return `
<div style="
background: url('/keji_border.png') no-repeat center center;
background-size: contain;
height: 150px;
width: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
padding: 10px;
box-sizing: border-box;
">
报警: ${itemWithId2.alarmCount}<br />
警情: ${itemWithId2.caseCount}<br />
AI预警: ${itemWithId2.aiCount}
</div>
`
}
} }
}, },
lines3D: { data: [] as any[] //
},
{
type: 'lines', // 线
tooltip: {
show: false // 线 tooltip
},
zlevel: 2,
effect: {
show: true, show: true,
data: [ period: 3, //
{ trailLength: 0.03, //[0,1]
coords: [ symbol: 'arrow', //
[111.51, 29.02], // symbolSize: 6 //
[109.22793, 29.12239] // },
], lineStyle: {
lineStyle: { color: '#EE5652',
width: 2, width: 1, //线
color: '#fff' opacity: 1, //线
} curveness: 0.3 //线
} },
// 线 data: linesData,
] symbol: ['none', 'circle'], //线
symbolSize: 10 // 线
},
{
//
type: 'effectScatter', //,
zlevel: 3, //
coordinateSystem: 'geo',
tooltip: {
show: false // tooltip
},
data: effectScatterData,
symbol: 'circle', //
symbolSize: [10, 10], // 20 10
itemStyle: {
color: 'orange', //
shadowBlur: 10, //
shadowColor: 'orange' //
},
effectType: 'ripple', //
// showEffectOn:emphasisrender
// showEffectOn:render:
showEffectOn: 'render',
rippleEffect: {
scale: 5, //
brushType: 'stroke' // stroke
} }
} }
] ]
} }
if (name !== '湖南省') {
myChart.setOption(option) // option.series = option.series.filter((series) => series.type !== 'lines')
option.series[1].data = []
option.series[2].data = []
myChart.setOption(option)
} else {
myChart.setOption(option)
}
window.addEventListener('resize', function () { window.addEventListener('resize', function () {
myChart.resize() myChart.resize()
}) })
@ -920,6 +1130,7 @@ const initMap2 = (arr: any) => {
<style scoped lang="scss"> <style scoped lang="scss">
:deep(.dv-scroll-board .header) { :deep(.dv-scroll-board .header) {
font-size: 13px; font-size: 13px;
;
} }
:deep(.dv-scroll-board .rows .row-item) { :deep(.dv-scroll-board .rows .row-item) {
@ -1137,6 +1348,8 @@ const initMap2 = (arr: any) => {
margin-right: 0.5%; margin-right: 0.5%;
border: 1px solid #3876B9; border: 1px solid #3876B9;
background-image: url(./indeximag/able.jpg); background-image: url(./indeximag/able.jpg);
// background-image: url(./indeximag/bg4.jpg);
background-size: 100% 100%; background-size: 100% 100%;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB