Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
scrm-wx-merchant-activity
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 778c4184
authored
Jul 04, 2023
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改地图
1 parent
08b23cc2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
95 deletions
package.json
src/api/mapApi.js
package.json
View file @
778c418
...
...
@@ -18,6 +18,7 @@
"build"
:
"^0.1.4"
,
"core-js"
:
"^3.6.4"
,
"dayjs"
:
"^1.10.5"
,
"glmap-jssdk"
:
"^1.0.1"
,
"glsx-common"
:
"^2.1.0"
,
"lib-flexible"
:
"^0.3.2"
,
"number-precision"
:
"^1.6.0"
,
...
...
src/api/mapApi.js
View file @
778c418
import
md5
from
'./utils/md5'
import
qs
from
'./utils/qs'
const
key
=
'F2HBZ-KH73F-7A2J2-JC4UR-WOHCO-UVFGZ'
const
secret
=
'YBmrM98E5pM4gYeknWiBPaWpFR4AISUl'
const
domain
=
'https://apis.map.qq.com'
class
QQMap
{
setLocaleCompare
(
params
)
{
params
.
key
=
key
let
keys
=
[]
let
obj
=
{}
Object
.
keys
(
params
).
map
(
e
=>
keys
.
push
(
e
))
keys
.
sort
((
a
,
b
)
=>
a
.
localeCompare
(
b
)).
map
(
e
=>
(
obj
[
e
]
=
params
[
e
]))
return
obj
}
getSign
(
params
,
methods
)
{
let
obj
=
this
.
setLocaleCompare
(
params
)
let
sign
=
`
${
methods
}
?
${
decodeURIComponent
(
qs
.
stringify
(
obj
))}${
secret
}
`
return
md5
(
sign
)
}
request
(
method
,
data
)
{
data
.
output
=
'jsonp'
// data.callback = 'test'
const
sig
=
this
.
getSign
(
data
,
method
)
let
obj
=
{
...
this
.
setLocaleCompare
(
data
),
sig
},
params
=
[]
Object
.
keys
(
obj
).
map
(
key
=>
{
params
.
push
(
`
${
key
}
=
${
encodeURIComponent
(
obj
[
key
])}
`
)
})
// window.fetch(`${domain}${method}?${params.join('&')}`, {
// method: 'GET',
// mode: 'no-cors',
// })
let
script
=
document
.
createElement
(
'script'
)
script
.
src
=
`
${
domain
}${
method
}
?
${
params
.
join
(
'&'
)}
`
script
.
type
=
'text/javascript'
document
.
body
.
insertBefore
(
script
,
document
.
body
.
children
[
0
])
return
new
Promise
((
resolve
,
reject
)
=>
{
window
[
'QQmap'
]
=
({
status
,
result
})
=>
{
console
.
log
(
result
)
if
(
status
==
'0'
)
resolve
(
result
)
else
reject
()
document
.
body
.
removeChild
(
script
)
}
})
}
/**计算距离 */
calculateDistance
(
from
,
to
)
{
from
=
from
.
join
(
','
)
to
=
to
.
join
(
','
)
return
this
.
request
(
'/ws/distance/v1/'
,
{
from
,
to
,
mode
:
'driving'
})
}
/** 批量距离计算(矩阵) */
calculateDistanceMatrix
(
from
,
toList
)
{
from
=
from
.
join
(
','
)
let
to
=
toList
.
join
(
';'
)
return
this
.
request
(
'/ws/distance/v1/matrix/'
,
{
from
,
to
,
mode
:
'driving'
})
}
/**地址解析(地址转坐标) */
geocoder
(
address
)
{
return
this
.
request
(
'/ws/geocoder/v1/'
,
{
address
})
}
/**逆地址解析(坐标位置描述) location=lat<纬度>,lng<经度> */
detailedAdrress
(
location
)
{
location
=
location
.
join
(
','
)
return
this
.
request
(
'/ws/geocoder/v1/'
,
{
location
})
}
/**IP定位 */
getLocationByIp
()
{
return
this
.
request
(
'/ws/location/v1/ip'
)
}
/**坐标转换 */
translate
(
locations
,
type
=
5
)
{
locations
=
locations
.
join
(
';'
)
//格式:纬度前,经度后
return
this
.
request
(
'/ws/coord/v1/translate'
,
{
locations
,
type
})
}
}
export
default
new
QQMap
()
import
GlMap
from
'glmap-jssdk'
export
default
new
GlMap
()
\ No newline at end of file
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