Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
oEshield
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 94b2ffb8
authored
Jan 17, 2025
by
wangzhihui
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复轨迹速度过慢问题
1 parent
c361d311
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
14 deletions
src/utils/mapBgeo.js
src/utils/replay.js
src/utils/mapBgeo.js
View file @
94b2ffb
...
...
@@ -2,7 +2,7 @@
* @Author: 'wangzhihui' '1733904062@qq.com'
* @Date: 2024-11-28 16:37:15
* @LastEditors: 'wangzhihui' '1733904062@qq.com'
* @LastEditTime: 2025-01-1
4 17:05:20
* @LastEditTime: 2025-01-1
6 11:15:49
* @FilePath: \oEshield\src\utils\mapgeo.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -10,7 +10,6 @@ const MAPGEO = {
geocoder
:
null
,
getGeocoder
:
function
()
{
return
new
Promise
((
resolve
)
=>
{
console
.
log
(
window
)
var
geocoder
=
AMap
.
invoke
(
'Geocoder'
);
// AMap.plugin('AMap.Geocoder', function () {//回调函数
// var geocoder = new AMap.Geocoder({
...
...
@@ -23,6 +22,7 @@ const MAPGEO = {
// })
},
transferAddressByGroup
(
obj
,
cb
)
{
console
.
log
(
obj
,
'obj'
)
if
(
!
this
.
geocoder
)
{
this
.
getGeocoder
().
then
(()
=>
{
this
.
transfer
(
obj
,
cb
)
...
...
@@ -79,7 +79,7 @@ const MAPGEO = {
arr
.
forEach
(
item
=>
{
let
o
=
AMap
.
invoke
(
'Point'
,...
item
)
MAPGEO
.
geocoder
.
getLocation
(
o
,
function
(
res
){
console
.
log
(
res
,
'res'
)
setAddress
(
o
,
res
);
obj
.
totalNum
++
;
if
(
obj
.
totalNum
===
obj
.
realNum
)
{
...
...
src/utils/replay.js
View file @
94b2ffb
...
...
@@ -21,6 +21,8 @@ const replay = {
times
:
1
,
timeoutIds
:
[],
data
:
[],
dis
:[],
distance
:
''
,
markers
:
{},
infowins
:
{},
speed
:
1
,
...
...
@@ -35,27 +37,35 @@ const replay = {
},
init
(){
var
replayData
=
[]
replay
.
data
.
forEach
(
function
(
item
){
var
replayData
=
[];
replay
.
data
.
reduce
(
function
(
prev
,
item
){
// console.log(prev ,item)
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
)
return
item
});
let
p1
=
replayData
[
0
];
let
p2
=
replayData
[
replayData
.
length
-
1
];
let
line
=
AMap
.
invoke
(
'Polyline'
,
replayData
,
{
strokeColor
:
'#0b94db'
,
strokeWeight
:
6
})
replay
.
startMarker
=
mapService
.
createStartMarker
(
p1
,
AMap
);
replay
.
endMarker
=
mapService
.
createEndMarker
(
p2
,
AMap
);
replay
.
dis
=
AMap
.
invoke
(
'getDistance'
,
p1
,
p2
)
/
1000
// 算出轨迹的距离(km)
//
replay.dis = AMap.invoke('getDistance', p1, p2)/1000 // 算出轨迹的距离(km)
AMap
.
invoke
(
'setViewport'
,
replayData
);
AMap
.
invoke
(
'addOverlay'
,
line
)
AMap
.
invoke
(
'addOverlay'
,
replay
.
startMarker
)
AMap
.
invoke
(
'addOverlay'
,
replay
.
endMarker
)
replay
.
distance
=
replay
.
dis
.
reduce
(
function
(
prev
,
cur
,
index
,
arr
)
{
return
prev
+
cur
;
});
// replay.distance= parseInt(replay.distance/1000)//算出轨迹的距离(km)
const
firstItem
=
replay
.
data
[
0
];
replay
.
navg
=
AMap
.
invoke
(
'LuShu'
,
replayData
,
{
defaultContent
:
replay
.
getNavgInfoContent
(
firstItem
),
autoView
:
true
,
// 是否开启自动视野调整,如果开启那么路书在运动过程中会根据视野自动调整
speed
:
replay
.
getSpeed
(
replay
.
speed
,
replay
.
dis
),
speed
:
replay
.
getSpeed
(
replay
.
speed
,
replay
.
dis
tance
),
icon
:
AMap
.
invoke
(
'Icon'
,
'https://e-shield-old.glsx.com.cn/images/icon_car.png'
,
AMap
.
invoke
(
'Size'
,
36
,
22
),{
anchor
:
AMap
.
invoke
(
'Size'
,
18
,
11
)
}),
enableRotation
:
true
,
// 是否设置marker随着道路的走向进行旋转
})
...
...
@@ -66,18 +76,19 @@ const replay = {
EventBus
.
$emit
(
'uiMap.replay.initDone'
)
AMap
.
invoke
(
'lushuAddEventListener'
,
'move'
,
(
e
)
=>
{
this
.
idx
=
e
.
target
.
i
;
console
.
log
(
this
.
idx
)
let
lnglat
=
replayData
[
this
.
idx
]
let
item
=
replay
.
data
[
this
.
idx
]
AMap
.
invoke
(
'lushuSetContent'
,
replay
.
getNavgInfoContent
(
item
))
//设置信息窗口文案
EventBus
.
$emit
(
'uiMap.replay.currAddress'
,
''
);
console
.
log
(
this
.
idx
,
replay
.
data
.
length
-
1
)
if
(
this
.
idx
>=
replay
.
data
.
length
-
2
){
EventBus
.
$emit
(
'uiMap.replay.done'
);
}
});
},
getDistance
(
p1
,
p2
)
{
return
AMap
.
invoke
(
'getDistance'
,
p1
,
p2
);
},
getNavgInfoContent
(
item
){
return
`<div class="navg-info-window">
<div class="tit">
${
item
.
dateTime
}
</div>
...
...
@@ -106,7 +117,9 @@ const replay = {
bindEvent
(){
//解析轨迹地址
EventBus
.
$on
(
'uiMap.replay.transferAdr'
,
function
(
data
){
// console.log(data)
replay
.
data
=
data
;
replay
.
transferAddressByGroup
();
});
...
...
@@ -237,15 +250,14 @@ const replay = {
// //mapService.setFitView(MAP);
// },
speedEvent
(
idx
,
dis
)
{
console
.
log
(
idx
,
dis
)
let
timeArr
=
[[
40
,
30
,
16
],
[
30
,
20
,
12
],
[
20
,
12
,
8
],
[
5
,
3
,
2
]]
// 慢 正常 快 很快
let
speed
if
(
dis
>=
100
)
{
// 100公里以上
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
0
])
*
3600
)
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
0
]))
}
else
if
(
dis
>
10
&&
dis
<
100
)
{
// 10-100公里
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
1
])
*
3600
)
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
1
]))
}
else
{
// 10公里以内
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
2
])
*
3600
)
speed
=
Math
.
floor
((
dis
/
timeArr
[
idx
][
2
]))
}
return
speed
},
...
...
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