Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
npm
/
glsk-map-sdk
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 383e1322
authored
Dec 19, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit 提交
1 parent
d9a2eca3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
16 deletions
dist/glsk-map-sdk.js → dist/glsk-mapapi-sdk.js
package-lock.json
package.json
rollup.config.js
src/index.js
dist/glsk-map-sdk.js
→
dist/glsk-map
api
-sdk.js
View file @
383e132
This diff is collapsed.
Click to expand it.
package-lock.json
View file @
383e132
{
{
"name"
:
"glsk-map-sdk"
,
"name"
:
"glsk-map
api
-sdk"
,
"version"
:
"0.1.
0
"
,
"version"
:
"0.1.
3
"
,
"lockfileVersion"
:
3
,
"lockfileVersion"
:
3
,
"requires"
:
true
,
"requires"
:
true
,
"packages"
:
{
"packages"
:
{
""
:
{
""
:
{
"name"
:
"glsk-map-sdk"
,
"name"
:
"glsk-map
api
-sdk"
,
"version"
:
"0.1.
0
"
,
"version"
:
"0.1.
3
"
,
"license"
:
"ISC"
,
"license"
:
"ISC"
,
"devDependencies"
:
{
"devDependencies"
:
{
"@babel/preset-env"
:
"^7.26.0"
,
"@babel/preset-env"
:
"^7.26.0"
,
...
...
package.json
View file @
383e132
{
{
"name"
:
"glsk-map-sdk"
,
"name"
:
"glsk-map
api
-sdk"
,
"version"
:
"0.1.
0
"
,
"version"
:
"0.1.
4
"
,
"type"
:
"module"
,
"type"
:
"module"
,
"description"
:
"glsk-map-sdk"
,
"description"
:
"glsk-map
api
-sdk"
,
"main"
:
"src/index.js"
,
"main"
:
"src/index.js"
,
"scripts"
:
{
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
...
...
rollup.config.js
View file @
383e132
...
@@ -7,7 +7,7 @@ export default {
...
@@ -7,7 +7,7 @@ export default {
input
:
'src/index.js'
,
input
:
'src/index.js'
,
output
:
[
output
:
[
{
{
file
:
'dist/glsk-map-sdk.js'
,
file
:
'dist/glsk-map
api
-sdk.js'
,
format
:
'umd'
,
format
:
'umd'
,
name
:
'GlMap'
,
name
:
'GlMap'
,
globals
:
{
globals
:
{
...
...
src/index.js
View file @
383e132
const
env
=
{
const
env
Object
=
{
1
:
'develop'
,
1
:
'develop'
,
2
:
'test'
,
2
:
'test'
,
3
:
'production'
,
3
:
'production'
,
...
@@ -6,24 +6,35 @@ const env = {
...
@@ -6,24 +6,35 @@ const env = {
}
}
class
GlMapSdk
{
class
GlMapSdk
{
constructor
()
{
constructor
()
{
let
envNumber
=
1
,
let
mapConfig
=
{
env
:
3
,
version
:
3
},
_callBack
=
arguments
[
0
]
_callBack
=
arguments
[
0
]
if
(
arguments
.
length
>
1
)
{
if
(
arguments
.
length
>
1
)
{
envNumber
=
arguments
[
0
]
mapConfig
=
typeof
arguments
[
0
]
==
'object'
?
arguments
[
0
]
:
mapConfig
_callBack
=
arguments
[
1
]
_callBack
=
arguments
[
1
]
if
(
!
mapConfig
?.
env
)
mapConfig
.
env
=
3
if
(
!
mapConfig
?.
version
)
mapConfig
.
version
=
3
}
}
if
(
typeof
window
!==
'undefined'
)
{
if
(
typeof
window
!==
'undefined'
)
{
const
fetchConfig
=
async
()
=>
{
const
fetchConfig
=
async
()
=>
{
try
{
try
{
console
.
log
(
envNumber
)
const
response
=
await
fetch
(
`https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=map-api-js&env=
${
envObject
[
mapConfig
.
env
]}
`
);
const
response
=
await
fetch
(
`https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=map-api-js&env=
${
env
[
envNumber
]}
`
);
const
res
=
await
response
.
json
(),
const
res
=
await
response
.
json
();
scriptExists
=
Array
.
from
(
document
.
head
.
getElementsByTagName
(
'script'
)).
some
(
script
=>
script
.
src
===
res
.
apiUrl
);
if
(
!
scriptExists
)
{
const
script
=
document
.
createElement
(
'script'
);
const
script
=
document
.
createElement
(
'script'
);
script
.
src
=
res
.
apiUrl
;
script
.
src
=
res
.
apiUrl
;
document
.
head
.
appendChild
(
script
)
document
.
head
.
appendChild
(
script
)
script
.
onload
=
()
=>
{
script
.
onload
=
()
=>
{
this
.
GLMap
=
new
window
.
$GlMapApi
(()
=>
{
this
.
GLMap
=
new
window
.
$GlMapApi
(
mapConfig
,
()
=>
{
_callBack
(
this
)
if
(
_callBack
&&
typeof
_callBack
==
'function'
)
_callBack
(
this
)
})
}
}
else
if
(
_callBack
&&
typeof
_callBack
==
'function'
)
{
this
.
GLMap
=
new
window
.
$GlMapApi
(
mapConfig
,
()
=>
{
if
(
_callBack
&&
typeof
_callBack
==
'function'
)
_callBack
(
this
)
})
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -37,5 +48,11 @@ class GlMapSdk {
...
@@ -37,5 +48,11 @@ class GlMapSdk {
let
params
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
)
let
params
=
Array
.
prototype
.
slice
.
call
(
arguments
,
1
)
return
this
.
GLMap
[
target
](...
params
)
return
this
.
GLMap
[
target
](...
params
)
}
}
get
map
()
{
return
this
.
GLMap
.
_BMAP
}
get
mapGL
()
{
return
this
.
GLMap
.
_BMapGL
}
}
}
export
default
GlMapSdk
export
default
GlMapSdk
\ No newline at end of file
\ 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