|
|
@@ -11,6 +11,7 @@ import { Tile, Vector as VectorLayer } from 'ol/layer' |
|
|
|
import TileWMS from 'ol/source/TileWMS.js' |
|
|
|
import LineString from 'ol/geom/LineString' |
|
|
|
import Point from 'ol/geom/Point' |
|
|
|
import { Style, Icon, Text, Fill } from 'ol/style' |
|
|
|
import { XYZ, Vector as VectorSource } from 'ol/source' |
|
|
|
import { transform, fromLonLat } from 'ol/proj' |
|
|
|
import { getVectorContext } from 'ol/render' |
|
|
@@ -19,6 +20,10 @@ import * as control from 'ol/control' |
|
|
|
import { styleList } from '@/utils/style.js' |
|
|
|
import { getTrackList } from '@/api/task/index.js' |
|
|
|
import { useInspectionStore } from '@/store/modules/inspection.js' |
|
|
|
import { airportList } from '@/api/dashboard/index.js' |
|
|
|
import { gcj02towgs84 } from '@/utils/coordinate-util.js' |
|
|
|
import uav_icon from '@/assets/images/airport.png' |
|
|
|
import gcj02Mecator from '@/utils/map/gcj02Mecator.js' |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'UnderLay', |
|
|
@@ -39,7 +44,9 @@ export default { |
|
|
|
// 轨迹数据 |
|
|
|
trackList: [], |
|
|
|
socket: null, |
|
|
|
liveTrackLayer: null |
|
|
|
liveTrackLayer: null, |
|
|
|
trackTimer: null, |
|
|
|
airLayer: null |
|
|
|
}) |
|
|
|
|
|
|
|
const getMapOptions = computed(() => { |
|
|
@@ -56,6 +63,7 @@ export default { |
|
|
|
const tdtImgMap = new Tile({ |
|
|
|
visible: true, |
|
|
|
source: new XYZ({ |
|
|
|
projection: gcj02Mecator, |
|
|
|
url: 'https://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=6&x={x}&y={y}&z={z}' |
|
|
|
}) |
|
|
|
}) |
|
|
@@ -96,11 +104,80 @@ export default { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const drawAirport = async(id) => { |
|
|
|
const res = await airportList({ page: 1, limit: 100 }) |
|
|
|
if (res.code === 0) { |
|
|
|
if (res.data.length > 0) { |
|
|
|
for (let i = 0; i < res.data.length; i++) { |
|
|
|
if (id === res.data[i].id) { |
|
|
|
const airport = res.data[i] |
|
|
|
const lngLat = gcj02towgs84( |
|
|
|
parseFloat(airport.longitude), |
|
|
|
parseFloat(airport.latitude) |
|
|
|
) |
|
|
|
const feature = new Feature({ |
|
|
|
geometry: new Point(fromLonLat(lngLat)) |
|
|
|
}) |
|
|
|
// 要素设置样式 |
|
|
|
feature.setStyle( |
|
|
|
new Style({ |
|
|
|
image: new Icon({ |
|
|
|
src: uav_icon |
|
|
|
}), |
|
|
|
text: new Text({ |
|
|
|
// 文字内容 |
|
|
|
text: airport.name, |
|
|
|
// 位置 |
|
|
|
textAlign: 'center', |
|
|
|
// 基准线 |
|
|
|
textBaseline: 'top', |
|
|
|
offsetY: 30, |
|
|
|
// 文字样式 |
|
|
|
font: 'normal 20px Microsoft YaHei', |
|
|
|
backgroundFill: new Fill({ |
|
|
|
color: '#1890FF' |
|
|
|
}), |
|
|
|
padding: [3, 6, 3, 6], |
|
|
|
// 文字颜色 |
|
|
|
fill: new Fill({ |
|
|
|
color: '#fff' |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
) |
|
|
|
// 要素设置id |
|
|
|
feature.setId(airport.id) |
|
|
|
// 添加矢量图层 |
|
|
|
data.airLayer = new VectorLayer({ |
|
|
|
source: new VectorSource({ |
|
|
|
features: [feature] |
|
|
|
}), |
|
|
|
visible: true |
|
|
|
}) |
|
|
|
data.map.addLayer(data.airLayer) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (inspectionStore.getList.id) { |
|
|
|
if (!data.map) { |
|
|
|
getTrackData().then(({ trackList }) => { |
|
|
|
setLiveTrack(formatTradeList(trackList)) |
|
|
|
}) |
|
|
|
data.trackTimer = setInterval(() => { |
|
|
|
getTrackData().then(({ trackList }) => { |
|
|
|
// 有数据了再画 |
|
|
|
if (trackList.length > 0) { |
|
|
|
clearInterval(data.trackTimer) |
|
|
|
data.trackTimer = null |
|
|
|
setLiveTrack(formatTradeList(trackList)) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 2000) |
|
|
|
|
|
|
|
// 绘制机场 |
|
|
|
if (inspectionStore.getList.airportId) { |
|
|
|
drawAirport(inspectionStore.getList.airportId) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -204,6 +281,9 @@ export default { |
|
|
|
const endLiveFly = () => { |
|
|
|
clearInterval(data.socket) |
|
|
|
data.socket = null |
|
|
|
if (data.airLayer) { |
|
|
|
data.map.removeLayer(data.airLayer) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
onMounted(() => { |