Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx-business
/
oms-tiger-shield
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit a681b8ae
authored
Jan 21, 2025
by
huyue
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复轨迹和激活位置点
1 parent
ba53a969
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
54 deletions
src/utils/monitor.js
src/utils/replay.js
src/views/report/location.vue
src/utils/monitor.js
View file @
a681b8a
...
@@ -368,7 +368,6 @@ const monitor = {
...
@@ -368,7 +368,6 @@ const monitor = {
// 激活位置
// 激活位置
drawMaker
(
data
,
autoOpenLastInfoWindow
,
mapapi
)
{
drawMaker
(
data
,
autoOpenLastInfoWindow
,
mapapi
)
{
console
.
log
(
mapapi
,
'drawMaker'
,
data
)
const
getLngLat
=
mapService
.
getLngLat
(
parseFloat
(
data
.
lng
),
parseFloat
(
data
.
lat
))
const
getLngLat
=
mapService
.
getLngLat
(
parseFloat
(
data
.
lng
),
parseFloat
(
data
.
lat
))
const
marker
=
mapService
.
createCarMarker
(
getLngLat
)
const
marker
=
mapService
.
createCarMarker
(
getLngLat
)
mapapi
.
invoke
(
'addOverlay'
,
marker
)
mapapi
.
invoke
(
'addOverlay'
,
marker
)
...
...
src/utils/replay.js
View file @
a681b8a
...
@@ -22,6 +22,8 @@ const replay = {
...
@@ -22,6 +22,8 @@ const replay = {
times
:
1
,
times
:
1
,
timeoutIds
:
[],
timeoutIds
:
[],
data
:
[],
data
:
[],
dis
:
[],
distance
:
''
,
markers
:
{},
markers
:
{},
infowins
:
{},
infowins
:
{},
speed
:
1
,
speed
:
1
,
...
@@ -36,24 +38,16 @@ const replay = {
...
@@ -36,24 +38,16 @@ const replay = {
})
})
},
},
init
()
{
init
()
{
// if (!replay.pathSPromise) {
// replay.pathSPromise = new Promise(function (resolve, reject) {
// AMapUI.load(['ui/misc/PathSimplifier'], function (PathSimplifier) {
// if (!PathSimplifier.supportCanvas) {
// alert('当前环境不支持 Canvas!')
// return
// }
// replay.PathS = PathSimplifier
// resolve()
// })
// })
// }
var
replayData
=
[]
var
replayData
=
[]
console
.
log
(
replay
,
'init'
)
console
.
log
(
replay
,
'init'
)
replay
.
data
.
forEach
(
function
(
item
)
{
replay
.
data
.
reduce
(
function
(
prev
,
item
){
const
lnglat
=
mapService
.
getLngLat
(
item
.
blng
,
item
.
blat
)
// const lnglat = mapService.getLngLat(item.blng, item.blat)
// replayData.push(lnglat)
let
prevLnglat
=
mapService
.
getLngLat
(
prev
.
blng
,
prev
.
blat
)
let
lnglat
=
mapService
.
getLngLat
(
item
.
blng
,
item
.
blat
)
replay
.
dis
.
push
(
replay
.
getDistance
(
prevLnglat
,
lnglat
))
replayData
.
push
(
lnglat
)
replayData
.
push
(
lnglat
)
return
item
})
})
const
self
=
this
const
self
=
this
const
MAP
=
mapService
.
map
const
MAP
=
mapService
.
map
...
@@ -63,8 +57,11 @@ const replay = {
...
@@ -63,8 +57,11 @@ const replay = {
const
line
=
mapapi
.
invoke
(
'Polyline'
,
replayData
,
{
strokeColor
:
'#0b94db'
,
strokeWeight
:
6
})
const
line
=
mapapi
.
invoke
(
'Polyline'
,
replayData
,
{
strokeColor
:
'#0b94db'
,
strokeWeight
:
6
})
replay
.
startMarker
=
mapService
.
createStartMarker
(
p1
,
mapapi
)
replay
.
startMarker
=
mapService
.
createStartMarker
(
p1
,
mapapi
)
replay
.
endMarker
=
mapService
.
createEndMarker
(
p2
,
mapapi
)
replay
.
endMarker
=
mapService
.
createEndMarker
(
p2
,
mapapi
)
replay
.
dis
=
mapapi
.
invoke
(
'getDistance'
,
p1
,
p2
)
/
1000
// 算出轨迹的距离(km)
// replay.dis = mapapi.invoke('getDistance', p1, p2) / 1000 // 算出轨迹的距离(km)
console
.
log
(
replay
.
dis
,
'km'
)
replay
.
distance
=
replay
.
dis
.
reduce
(
function
(
prev
,
cur
,
index
,
arr
)
{
return
prev
+
cur
;
});
// console.log(replay.dis, 'km')
mapapi
.
invoke
(
'setViewport'
,
replayData
)
mapapi
.
invoke
(
'setViewport'
,
replayData
)
mapapi
.
invoke
(
'addOverlay'
,
line
)
mapapi
.
invoke
(
'addOverlay'
,
line
)
mapapi
.
invoke
(
'addOverlay'
,
replay
.
startMarker
)
mapapi
.
invoke
(
'addOverlay'
,
replay
.
startMarker
)
...
@@ -74,7 +71,7 @@ const replay = {
...
@@ -74,7 +71,7 @@ const replay = {
replay
.
navg
=
mapapi
.
invoke
(
'LuShu'
,
replayData
,
{
replay
.
navg
=
mapapi
.
invoke
(
'LuShu'
,
replayData
,
{
defaultContent
:
replay
.
getNavgInfoContent
(
firstItem
),
defaultContent
:
replay
.
getNavgInfoContent
(
firstItem
),
autoView
:
true
,
// 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
autoView
:
true
,
// 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
speed
:
replay
.
getSpeed
(
replay
.
speed
,
replay
.
dis
),
speed
:
replay
.
getSpeed
(
replay
.
speed
,
replay
.
dis
tance
/
1000
),
icon
:
mapapi
.
invoke
(
'Icon'
,
'https://e-shield-old.glsx.com.cn/images/icon_car.png'
,
mapapi
.
invoke
(
'Size'
,
36
,
22
),
{
anchor
:
mapapi
.
invoke
(
'Size'
,
18
,
11
)
}),
icon
:
mapapi
.
invoke
(
'Icon'
,
'https://e-shield-old.glsx.com.cn/images/icon_car.png'
,
mapapi
.
invoke
(
'Size'
,
36
,
22
),
{
anchor
:
mapapi
.
invoke
(
'Size'
,
18
,
11
)
}),
enableRotation
:
true
// 是否设置marker随着道路的走向进行旋转
enableRotation
:
true
// 是否设置marker随着道路的走向进行旋转
})
})
...
@@ -186,6 +183,10 @@ const replay = {
...
@@ -186,6 +183,10 @@ const replay = {
// }
// }
// })
// })
},
},
getDistance
(
p1
,
p2
)
{
const
mapapi
=
mapService
.
mapapi
return
mapapi
.
invoke
(
'getDistance'
,
p1
,
p2
);
},
getNavgInfoContent
(
item
)
{
getNavgInfoContent
(
item
)
{
return
`<div class="navg-info-window">
return
`<div class="navg-info-window">
<div class="tit">
${
item
.
time
}
</div>
<div class="tit">
${
item
.
time
}
</div>
...
@@ -358,7 +359,7 @@ const replay = {
...
@@ -358,7 +359,7 @@ const replay = {
},
},
speedEvent
(
idx
,
dis
)
{
speedEvent
(
idx
,
dis
)
{
console
.
log
(
idx
,
dis
)
console
.
log
(
idx
,
dis
)
const
timeArr
=
[[
40
,
30
,
16
],
[
30
,
20
,
12
],
[
20
,
12
,
8
],
[
10
,
6
,
4
],
[
5
,
3
,
2
]]
// 慢 正常 快 很快
const
timeArr
=
[[
40
,
30
,
16
],
[
30
,
20
,
12
],
[
20
,
12
,
8
],
[
10
,
6
,
4
],
[
5
,
3
,
2
]]
// 慢 正常 快 很快
极快
let
speed
let
speed
if
(
dis
>=
100
)
{
// 100公里以上
if
(
dis
>=
100
)
{
// 100公里以上
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
0
])
*
3600
)
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
0
])
*
3600
)
...
@@ -367,6 +368,7 @@ const replay = {
...
@@ -367,6 +368,7 @@ const replay = {
}
else
{
// 10公里以内
}
else
{
// 10公里以内
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
2
])
*
3600
)
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
2
])
*
3600
)
}
}
console
.
log
(
speed
);
return
speed
return
speed
},
},
getSpeed
(
idx
,
dis
)
{
getSpeed
(
idx
,
dis
)
{
...
...
src/views/report/location.vue
View file @
a681b8a
...
@@ -24,53 +24,59 @@ export default {
...
@@ -24,53 +24,59 @@ export default {
};
};
},
},
created
()
{
created
()
{
if
(
window
.
AMap
)
{
//
if (window.AMap) {
this
.
initMap
();
this
.
initMap
();
}
else
{
//
} else {
remoteLoad
(
`
${
CONSTANT
.
AMAP_URL
}
`
).
then
(()
=>
{
//
remoteLoad(`${CONSTANT.AMAP_URL}`).then(() => {
remoteLoad
(
`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`
).
then
(
//
remoteLoad(`https://webapi.amap.com/ui/1.0/main.js?v=1.0.11`).then(
()
=>
{
//
() => {
this
.
initMap
();
//
this.initMap();
}
//
}
);
//
);
});
//
});
}
//
}
},
},
methods
:
{
methods
:
{
// 初始化地图
// 初始化地图
initMap
()
{
async
initMap
()
{
let
check
=
()
=>
{
this
.
mapapi
=
await
mapService
.
init
(
'map'
,
{
zoom
:
15
})
if
(
this
.
checkLoadedTimeoutId
)
{
window
.
GBMap
=
this
.
mapapi
window
.
clearTimeout
(
this
.
checkLoadedTimeoutId
);
}
return
setTimeout
(()
=>
{
if
(
"AMap"
in
window
&&
typeof
AMap
.
Map
==
"function"
&&
!
this
.
mapObj
)
{
window
.
AMap
=
AMap
;
this
.
mapObj
=
mapService
.
init
(
"map"
);
this
.
isInitMap
=
true
;
let
o
=
this
.
$route
.
query
;
let
o
=
this
.
$route
.
query
;
if
(
o
.
sn
)
{
if
(
o
.
sn
)
{
this
.
getLocation
(
o
.
sn
);
this
.
getLocation
(
o
.
sn
);
// o.blat = o.lat;
// o.blng = o.lng;
// this.addLocation(o);
}
}
else
{
this
.
checkLoadedTimeoutId
=
check
();
}
}
},
100
);
// let check = () => {
};
// if (this.checkLoadedTimeoutId) {
this
.
checkLoadedTimeoutId
=
check
();
// window.clearTimeout(this.checkLoadedTimeoutId);
// }
// return setTimeout(() => {
// if (
// "AMap" in window &&
// typeof AMap.Map == "function" &&
// !this.mapObj
// ) {
// window.AMap = AMap;
// this.mapObj = mapService.init("map");
// this.isInitMap = true;
// let o = this.$route.query;
// if (o.sn) {
// this.getLocation(o.sn);
// // o.blat = o.lat;
// // o.blng = o.lng;
// // this.addLocation(o);
// }
// } else {
// this.checkLoadedTimeoutId = check();
// }
// }, 100);
// };
// this.checkLoadedTimeoutId = check();
},
},
// 添加位置点
// 添加位置点
addLocation
(
row
)
{
addLocation
(
row
)
{
let
drawData
=
row
;
let
drawData
=
row
;
EventBus
.
$emit
(
"uiMap.monitor.drawMaker"
,
drawData
,
true
);
EventBus
.
$emit
(
"uiMap.monitor.drawMaker"
,
drawData
,
true
,
this
.
mapapi
);
},
},
// 获取位置信息
// 获取位置信息
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment