|
@@ -125,7 +125,7 @@ export default defineComponent({
|
|
|
let isFeature = false
|
|
|
e.map.forEachFeatureAtPixel(e.pixel, (f) => {
|
|
|
if (!isFeature) {
|
|
|
- if (f.get('_trackId') && !state.trackMap.has(f.get('_trackId')) && f.get('_historyWsUrl')) {
|
|
|
+ if (f.get('_trackId') && !state.trackMap.has(f.get('_trackId'))) {
|
|
|
isFeature = true
|
|
|
if (f.get('featureType') === 'ship') {
|
|
|
handleShipClick(f)
|
|
@@ -187,25 +187,27 @@ export default defineComponent({
|
|
|
trackTime: '?'
|
|
|
})
|
|
|
initWebSocketShip()
|
|
|
- const hWs = new WebSocket(clickFeat.get('_historyWsUrl'))
|
|
|
- hWs.onopen = (e) => {
|
|
|
- const str = {
|
|
|
- ...clickFeat.get('_historyWsOtherParams'),
|
|
|
- endTime: that.$util.YMDHms(new Date().getTime() + 1000 * 60 * 10),
|
|
|
- shipId: trackId,
|
|
|
- startTime: that.$util.YMDHms(new Date().getTime() - 1000 * 60 * 60 * 4)
|
|
|
+ if (clickFeat.get('_historyWsUrl')) {
|
|
|
+ const hWs = new WebSocket(clickFeat.get('_historyWsUrl'))
|
|
|
+ hWs.onopen = (e) => {
|
|
|
+ const str = {
|
|
|
+ ...clickFeat.get('_historyWsOtherParams'),
|
|
|
+ endTime: that.$util.YMDHms(new Date().getTime() + 1000 * 60 * 10),
|
|
|
+ shipId: trackId,
|
|
|
+ startTime: that.$util.YMDHms(new Date().getTime() - 1000 * 60 * 60 * 4)
|
|
|
+ }
|
|
|
+ hWs.send(JSON.stringify(str))
|
|
|
}
|
|
|
- hWs.send(JSON.stringify(str))
|
|
|
- }
|
|
|
- hWs.onmessage = (e) => {
|
|
|
- try {
|
|
|
- const json = JSON.parse(e.data)
|
|
|
- const s = 'json' + clickFeat.get('_historyWsDataFlag')
|
|
|
- const data = eval(s)
|
|
|
- const _historyData = [...state.trackMap.get(trackId).historyData, ...data]
|
|
|
- state.trackMap.set(trackId, Object.assign(state.trackMap.get(trackId), {historyData: _historyData}))
|
|
|
- draw()
|
|
|
- } catch (e) {
|
|
|
+ hWs.onmessage = (e) => {
|
|
|
+ try {
|
|
|
+ const json = JSON.parse(e.data)
|
|
|
+ const s = 'json' + clickFeat.get('_historyWsDataFlag')
|
|
|
+ const data = eval(s)
|
|
|
+ const _historyData = [...state.trackMap.get(trackId).historyData, ...data]
|
|
|
+ state.trackMap.set(trackId, Object.assign(state.trackMap.get(trackId), {historyData: _historyData}))
|
|
|
+ draw()
|
|
|
+ } catch (e) {
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
rWs.onopen = (e) => {
|
|
@@ -256,9 +258,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
lineArr.push(getKeyData('historyTrackWktKey'))
|
|
|
- if (i === 0) {
|
|
|
- timeArr.push(getKeyData('historyTrackTimeKey'))
|
|
|
- } else if (i === state.trackMap.get(trackId).historyData.length - 1) {
|
|
|
+ if (i === 0 || i === state.trackMap.get(trackId).historyData.length - 1) {
|
|
|
timeArr.push(getKeyData('historyTrackTimeKey'))
|
|
|
}
|
|
|
})
|
|
@@ -272,9 +272,7 @@ export default defineComponent({
|
|
|
}
|
|
|
}
|
|
|
lineArr.push(getKeyData('trackWktKey'))
|
|
|
- if (i === 0) {
|
|
|
- timeArr.push(getKeyData('trackTimeKey'))
|
|
|
- } else if (i === state.trackMap.get(trackId).historyData.length - 1) {
|
|
|
+ if (i === 0 || i === state.trackMap.get(trackId).realData.length - 1) {
|
|
|
timeArr.push(getKeyData('trackTimeKey'))
|
|
|
}
|
|
|
})
|