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 ceb6cfba
authored
Aug 01, 2023
by
前端
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.22.0' into 'master'
V1.22.0版本需求已上线合并代码到master See merge request
!58
2 parents
e459ffff
f026d3fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
75 deletions
src/utils/mapgeo.js
src/utils/mapgeo.js
View file @
ceb6cfb
const
MAPGEO
=
{
const
MAPGEO
=
{
geocoder
:
null
,
geocoder
:
null
,
getGeocoder
:
function
(){
getGeocoder
:
function
()
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
AMap
.
service
(
'AMap.Geocoder'
,
function
(){
//回调函数
AMap
.
service
(
"AMap.Geocoder"
,
function
()
{
var
geocoder
=
new
AMap
.
Geocoder
({
//回调函数
batch
:
true
var
geocoder
=
new
AMap
.
Geocoder
({
});
batch
:
true
,
MAPGEO
.
geocoder
=
geocoder
;
});
resolve
(
geocoder
);
MAPGEO
.
geocoder
=
geocoder
;
});
resolve
(
geocoder
);
})
});
},
});
transferAddressByGroup
(
obj
,
cb
){
},
if
(
!
this
.
geocoder
){
transferAddressByGroup
(
obj
,
cb
)
{
this
.
getGeocoder
().
then
(()
=>
{
if
(
!
this
.
geocoder
)
{
this
.
transfer
(
obj
,
cb
)
this
.
getGeocoder
().
then
(()
=>
{
})
this
.
transfer
(
obj
,
cb
);
}
else
{
});
this
.
transfer
(
obj
,
cb
)
}
else
{
}
this
.
transfer
(
obj
,
cb
);
},
}
transfer
(
obj
,
cb
){
},
const
data
=
obj
.
data
;
transfer
(
obj
,
cb
)
{
obj
.
len
=
data
.
length
;
const
data
=
obj
.
data
;
obj
.
times
=
obj
.
len
>
20
?
Math
.
ceil
(
obj
.
len
/
20
):
1
;
obj
.
len
=
data
.
length
;
obj
.
totalNum
=
0
;
obj
.
times
=
obj
.
len
>
20
?
Math
.
ceil
(
obj
.
len
/
20
)
:
1
;
obj
.
realNum
=
0
;
//为了剔除脏数据,脏数据导致解析不回调
obj
.
totalNum
=
0
;
for
(
let
i
=
0
;
i
<
obj
.
times
;
i
++
){
obj
.
realNum
=
0
;
//为了剔除脏数据,脏数据导致解析不回调
let
lnglatArr
=
[];
for
(
let
i
=
0
;
i
<
obj
.
times
;
i
++
)
{
let
initIdx
=
i
*
20
;
let
lnglatArr
=
[];
let
maxIdx
=
i
===
obj
.
times
-
1
?
obj
.
len
:(
i
+
1
)
*
20
;
let
initIdx
=
i
*
20
;
for
(
let
idx
=
initIdx
;
idx
<
maxIdx
;
idx
++
){
let
maxIdx
=
i
===
obj
.
times
-
1
?
obj
.
len
:
(
i
+
1
)
*
20
;
for
(
let
idx
=
initIdx
;
idx
<
maxIdx
;
idx
++
)
{
// 防止出现gps点:.00000的错误
// 防止出现gps点:.00000的错误
if
(
Number
(
data
[
idx
].
elng
)
>
0
&&
Number
(
data
[
idx
].
elat
)
>
0
)
{
if
(
Number
(
data
[
idx
].
elng
)
>
0
&&
Number
(
data
[
idx
].
elat
)
>
0
)
{
lnglatArr
.
push
([
data
[
idx
].
elng
,
data
[
idx
].
elat
])
lnglatArr
.
push
([
data
[
idx
].
elng
,
data
[
idx
].
elat
]);
obj
.
realNum
++
;
obj
.
realNum
++
;
}
}
}
(
function
(
initIdx
){
geocoderGetAdr
(
lnglatArr
,
initIdx
)
})(
initIdx
)
}
function
fixed6
(
num
){
return
Number
(
num
).
toFixed
(
6
);
}
}
function
geocoderGetAdr
(
arr
,
initIdx
){
(
function
(
initIdx
)
{
const
timeoutId
=
window
.
setTimeout
(()
=>
{
geocoderGetAdr
(
lnglatArr
,
initIdx
);
MAPGEO
.
geocoder
.
getAddress
(
arr
,
function
(
status
,
result
)
{
})(
initIdx
);
if
(
status
===
'complete'
&&
result
.
info
===
'OK'
)
{
//获取地址成功
}
result
.
regeocodes
.
forEach
((
item
,
idx
)
=>
{
function
fixed6
(
num
)
{
let
o
=
arr
[
idx
]
return
Number
(
num
).
toFixed
(
6
);
// limin 20230627 arr经纬度会被改成四舍五入6位小数 导致比较得不出index.方案:全部转成四舍五入6位再比较
}
// let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
let
_idx
=
data
.
findIndex
(
k
=>
fixed6
(
k
.
elng
)
==
fixed6
(
o
.
lng
)
&&
fixed6
(
k
.
elat
)
==
fixed6
(
o
.
lat
));
//data[initIdx + idx].transferAddress = item.formattedAddress;
data
[
_idx
].
transferAddress
=
item
.
formattedAddress
;
obj
.
totalNum
++
;
});
if
(
obj
.
totalNum
===
obj
.
realNum
){
cb
&&
cb
(
data
)
//ifPlay && obj.init(data)
//EventBus.$emit('uiMap.replay.transferAdrDone');
}
}
else
{
geocoderGetAdr
(
arr
,
initIdx
)
}
});
});
if
(
!
obj
.
timeoutIds
){
// 循环设置地址,修复数组中相同经纬度只设置第一个的bug jack 20230720
obj
.
timeoutIds
=
[]
function
setAddress
(
row
,
item
){
}
let
_list
=
data
.
filter
(
k
=>
fixed6
(
k
.
elng
)
==
fixed6
(
row
.
lng
)
&&
obj
.
timeoutIds
.
push
(
timeoutId
)
fixed6
(
k
.
elat
)
==
fixed6
(
row
.
lat
));
}
_list
.
map
(
k
=>
{
k
.
transferAddress
=
item
.
formattedAddress
})
}
}
}
export
default
MAPGEO
function
geocoderGetAdr
(
arr
,
initIdx
)
{
const
timeoutId
=
window
.
setTimeout
(()
=>
{
MAPGEO
.
geocoder
.
getAddress
(
arr
,
function
(
status
,
result
)
{
if
(
status
===
"complete"
&&
result
.
info
===
"OK"
)
{
//获取地址成功
result
.
regeocodes
.
forEach
((
item
,
idx
)
=>
{
let
o
=
arr
[
idx
];
// limin 20230627 arr经纬度会被改成四舍五入6位小数 导致比较得不出index.方案:全部转成四舍五入6位再比较
// let _idx = data.findIndex(k => k.elng == o.lng && k.elat == o.lat);
// let _idx = data.findIndex(
// (k) =>
// fixed6(k.elng) == fixed6(o.lng) &&
// fixed6(k.elat) == fixed6(o.lat)
// );
//data[initIdx + idx].transferAddress = item.formattedAddress;
//data[_idx].transferAddress = item.formattedAddress;
setAddress
(
o
,
item
)
obj
.
totalNum
++
;
});
if
(
obj
.
totalNum
===
obj
.
realNum
)
{
cb
&&
cb
(
data
);
//ifPlay && obj.init(data)
//EventBus.$emit('uiMap.replay.transferAdrDone');
}
}
else
{
geocoderGetAdr
(
arr
,
initIdx
);
}
});
});
if
(
!
obj
.
timeoutIds
)
{
obj
.
timeoutIds
=
[];
}
obj
.
timeoutIds
.
push
(
timeoutId
);
}
},
};
export
default
MAPGEO
;
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