feature:代码初始化。
This commit is contained in:
137
src/config/map.js
Normal file
137
src/config/map.js
Normal file
@@ -0,0 +1,137 @@
|
||||
import { getAssetsFile } from '@/utils'
|
||||
|
||||
export const mapConfig = {
|
||||
zoom: 13,
|
||||
minZoom: 4,
|
||||
maxZoom: 18,
|
||||
pitch: 0,
|
||||
center: ['120.43325056066504', '36.183868828044005'],
|
||||
logoVisible: false
|
||||
}
|
||||
|
||||
// 地图瓦片
|
||||
export const layerUrl = [
|
||||
{
|
||||
url: 'https://t1.tianditu.gov.cn/DataServer?T=vec_w&X={x}&Y={y}&L={z}&tk=85c9d12d5d691d168ba5cb6ecaa749eb',
|
||||
name: 'map',
|
||||
id: '2'
|
||||
},
|
||||
{
|
||||
url: 'https://t1.tianditu.gov.cn/DataServer?T=cva_w&X={x}&Y={y}&L={z}&tk=85c9d12d5d691d168ba5cb6ecaa749eb',
|
||||
name: 'title',
|
||||
id: '3'
|
||||
}
|
||||
]
|
||||
|
||||
// 所有在地图上打点的图片
|
||||
const arr = [
|
||||
'distributionCabinet_error',
|
||||
'distributionCabinet_online',
|
||||
'distributionCabinet_offline',
|
||||
'distributionCabinet_selected',
|
||||
'camera_error',
|
||||
'camera_online',
|
||||
'camera_offline',
|
||||
'lightControl_error',
|
||||
'lightControl_online',
|
||||
'lightControl_offline',
|
||||
'pole_left',
|
||||
'pole_right_online',
|
||||
'pole_right_error',
|
||||
'pole_selected'
|
||||
]
|
||||
|
||||
export const imageArr = arr.map((item) => {
|
||||
return {
|
||||
name: item,
|
||||
path: getAssetsFile(`monitor/${item}.png`)
|
||||
}
|
||||
})
|
||||
|
||||
// 配置地图上的点
|
||||
const configFn = (name, sizeX = 24, sizeY = 30.5, offset = 15.25 + 5) => {
|
||||
return {
|
||||
layerAttr: { name, zIndex: '102' },
|
||||
shapeName: 'name',
|
||||
shapeArr: [name],
|
||||
eventArr: ['click', 'mouseenter', 'mouseout', 'dragstart', 'dragging', 'dragend'],
|
||||
size: [sizeX, sizeY],
|
||||
style: {
|
||||
offsets: [0, offset]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const poleRightOnlineConfig = configFn('pole_right_online', 41, 94, 47 - 10)
|
||||
export const poleRightErrorConfig = configFn('pole_right_error', 41, 94, 47 - 10)
|
||||
export const distributionCabinetConfigOnline = configFn('distributionCabinet_online')
|
||||
export const distributionCabinetConfigError = configFn('distributionCabinet_error')
|
||||
|
||||
export const linearConfig = {
|
||||
layerAttr: { name: 'linear' },
|
||||
eventArr: ['click', 'mouseenter', 'mouseout']
|
||||
}
|
||||
|
||||
export const getPointData = (originArr) => {
|
||||
const arr = originArr.map((item, index) => {
|
||||
return {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
id: `point-${index}`,
|
||||
pointId: item.id,
|
||||
status: item.status,
|
||||
lonLat: item.lonLat,
|
||||
isHover: false,
|
||||
isActive: false,
|
||||
isDrag: false,
|
||||
createTime: 1706522289993
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: item.lonLat?.split(',').map(Number)
|
||||
}
|
||||
}
|
||||
})
|
||||
return arr
|
||||
}
|
||||
|
||||
export const getLineData = (originArr) => {
|
||||
return originArr.map((item, index) => {
|
||||
const lonLatArr = item.lonLat.split(';')
|
||||
const nodesArr = lonLatArr.map((II, idx) => {
|
||||
return {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
id: `point-${idx}`,
|
||||
isHover: false,
|
||||
isActive: false,
|
||||
isDrag: false,
|
||||
createTime: 1706166483706
|
||||
},
|
||||
geometry: {
|
||||
type: 'Point',
|
||||
coordinates: II.split(',').map(Number)
|
||||
}
|
||||
}
|
||||
})
|
||||
return {
|
||||
type: 'Feature',
|
||||
properties: {
|
||||
id: `line-${index}`,
|
||||
lineId: item.id,
|
||||
isHover: false,
|
||||
isActive: false,
|
||||
isDrag: false,
|
||||
isDraw: false,
|
||||
createTime: 1706166483707,
|
||||
nodes: nodesArr
|
||||
},
|
||||
geometry: {
|
||||
type: 'LineString',
|
||||
coordinates: item.lonLat.split(';').map((ii) => {
|
||||
return ii.split(',').map(Number)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user