Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
micro_app
gk
Commits
428ccf9d
Commit
428ccf9d
authored
Jul 08, 2025
by
daniel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(demo): 新增mapbox地图demo
parent
87c933ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
276 deletions
+109
-276
demo.jsp
src/main/webapp/WEB-INF/views/cmpt/demo.jsp
+109
-276
No files found.
src/main/webapp/WEB-INF/views/cmpt/demo.jsp
View file @
428ccf9d
...
@@ -26,10 +26,17 @@
...
@@ -26,10 +26,17 @@
src=
"https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"
></script>
src=
"https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"
></script>
<script
nomodule
<script
nomodule
src=
"https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"
></script>
src=
"https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"
></script>
<!-- 添加Mapbox GL JS CSS -->
<link
href=
"https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css"
rel=
"stylesheet"
>
<!-- 添加Mapbox GL JS -->
<script
src=
"https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js"
></script>
<!-- Favicon-->
<!-- Favicon-->
<link
rel=
"shortcut icon"
href=
"https://img.geexek.com/files/home/favicon.ico"
>
<link
rel=
"shortcut icon"
href=
"https://img.geexek.com/files/home/favicon.ico"
>
<!-- 自定义css -->
<!-- 自定义css -->
<link
rel=
"stylesheet"
href=
"${ctxStatic}/css/base.css"
>
<link
rel=
"stylesheet"
href=
"${ctxStatic}/css/base.css"
>
<!-- 添加天地图API -->
<script
src=
"https://api.tianditu.gov.cn/api?v=4.0&tk=16a595e56ea0cec57ad8c07368d7f1ac"
></script>
<style>
<style>
...
@@ -54,7 +61,6 @@
...
@@ -54,7 +61,6 @@
</head>
</head>
<body>
<body>
<jsp:include
page=
"../common/header.jsp"
></jsp:include>
<div
class=
"page-content d-flex align-items-stretch main-body"
>
<div
class=
"page-content d-flex align-items-stretch main-body"
>
<div
id=
"app"
v-cloak
>
<div
id=
"app"
v-cloak
>
<n-config-provider>
<n-config-provider>
...
@@ -69,294 +75,121 @@
...
@@ -69,294 +75,121 @@
</div>
</div>
</div>
</div>
<script
type=
"text/x-template"
id=
"my-app"
>
<script
type=
"text/x-template"
id=
"my-app"
>
<
n
-
space
>
<
div
style
=
"position: fixed; top: 0; left: 0; right: 0; bottom: 0; margin: 0; padding: 0;"
>
<
n
-
button
tertiary
>
<
div
ref
=
"mapContainer"
style
=
"width: 100%; height: 100%;"
><
/div
>
Default
<
/div
>
<
/n-button
>
<
n
-
button
tertiary
type
=
"primary"
>
Primary
<
/n-button
>
<
n
-
button
tertiary
type
=
"info"
>
Info
<
/n-button
>
<
n
-
button
tertiary
type
=
"success"
>
Success
<
/n-button
>
<
n
-
button
tertiary
type
=
"warning"
>
Warning
<
/n-button
>
<
n
-
button
tertiary
type
=
"error"
>
Error
<
/n-button
>
<
n
-
button
tertiary
round
>
Default
<
/n-button
>
<
n
-
button
tertiary
round
type
=
"primary"
>
Primary
<
/n-button
>
<
n
-
button
tertiary
round
type
=
"info"
>
Info
<
/n-button
>
<
n
-
button
tertiary
round
type
=
"success"
>
Success
<
/n-button
>
<
n
-
button
tertiary
round
type
=
"warning"
>
Warning
<
/n-button
>
<
n
-
button
tertiary
round
type
=
"error"
>
Error
<
/n-button
>
<
n
-
button
tertiary
circle
>
<
template
#
icon
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/template
>
<
/n-button
>
<
n
-
button
tertiary
circle
type
=
"primary"
>
<
template
#
icon
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/template
>
<
/n-button
>
<
n
-
button
tertiary
circle
type
=
"info"
>
<
template
#
icon
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/template
>
<
/n-button
>
<
n
-
button
tertiary
circle
type
=
"success"
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/n-button
>
<
n
-
button
tertiary
circle
type
=
"warning"
>
<
template
#
icon
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/template
>
<
/n-button
>
<
n
-
button
tertiary
circle
type
=
"error"
>
<
template
#
icon
>
<
n
-
icon
>
<
ion
-
icon
name
=
"cash"
><
/ion-icon
>
<
/n-icon
>
<
/template
>
<
/n-button
>
<
/n-space
>
<
n
-
dropdown
trigger
=
"hover"
:
options
=
"options"
@
select
=
"handleSelect"
>
<
n
-
button
>
找个地方休息
<
/n-button
>
<
/n-dropdown
>
<
n
-
space
>
<
n
-
tag
>
Real
Love
<
/n-tag
>
<
n
-
tag
type
=
"success"
>
Yes
It
Is
<
/n-tag
>
<
n
-
tag
type
=
"warning"
>
I
'm Down
</n-tag>
<n-tag type="error">
Yesterday
</n-tag>
<n-tag type="info">
I'
m
Looking
Through
You
<
/n-tag
>
<
/n-space
>
<
n
-
form
ref
=
"formRef"
inline
:
label
-
width
=
"80"
:
model
=
"formValue"
:
rules
=
"rules"
size
=
"small"
>
<
n
-
form
-
item
label
=
"Name"
path
=
"user.name"
>
<
n
-
input
v
-
model
:
value
=
"formValue.user.name"
placeholder
=
"Input Name"
/>
<
/n-form-item
>
<
n
-
form
-
item
label
=
"Age"
path
=
"user.age"
>
<
n
-
input
v
-
model
:
value
=
"formValue.user.age"
placeholder
=
"Input Age"
/>
<
/n-form-item
>
<
n
-
form
-
item
label
=
"Phone"
path
=
"phone"
>
<
n
-
input
v
-
model
:
value
=
"formValue.phone"
placeholder
=
"Phone Number"
/>
<
/n-form-item
>
<
n
-
form
-
item
>
<
n
-
button
@
click
=
"handleValidateClick"
>
Validate
<
/n-button
>
<
/n-form-item
>
<
/n-form
>
<
pre
>
{{
JSON
.
stringify
(
formValue
,
null
,
2
)
}}
<
/pre
>
<
n
-
slider
v
-
model
:
value
=
"slide"
:
step
=
"10"
/>
<
n
-
time
-
picker
default
-
formatted
-
value
=
"00:12:13"
/>
<
n
-
data
-
table
:
columns
=
"columns"
:
data
=
"data"
:
pagination
=
"pagination"
:
bordered
=
"false"
/>
<
n
-
button
@
click
=
"handleClick"
>
Start
me
up
<
/n-button
>
<
n
-
modal
title
=
"Card preset draggable"
preset
=
"card"
draggable
v
-
model
:
show
=
"showModal"
>
<
n
-
card
style
=
"width: 600px"
title
=
"Modal"
:
bordered
=
"false"
size
=
"huge"
role
=
"dialog"
aria
-
modal
=
"true"
>
666
s
<
/n-card
>
<
/n-modal
>
<
n
-
space
>
<
n
-
button
@
click
=
"notify('info')"
>
Info
<
/n-button
>
<
n
-
button
@
click
=
"notify('success')"
>
Success
<
/n-button
>
<
n
-
button
@
click
=
"notify('warning')"
>
Warning
<
/n-button
>
<
n
-
button
@
click
=
"notify('error')"
>
Error
<
/n-button
>
<
/n-space
>
</script>
</script>
<script>
<script>
const
{
createApp
,
defineComponent
,
ref
}
=
Vue
;
const
{
createApp
,
defineComponent
,
ref
,
onMounted
}
=
Vue
;
const
{
useMessage
,
useNotification
}
=
naive
const
{
useMessage
,
useNotification
}
=
naive
const
tk
=
"16a595e56ea0cec57ad8c07368d7f1ac"
const
mapBoxToken
=
'pk.eyJ1IjoieGluZ3NhaSIsImEiOiJjbTc0ZXJ4ZjgwOWF3MmtyMjFxN2E2MHo0In0.pknVy3Lq6fLcXiwvrVLcFg'
// 获取天地图的地址
const
getTDTUrls
=
()
=>
{
const
services
=
Array
.
from
({
length
:
7
},
(
_
,
i
)
=>
i
+
1
);
const
baseUrl
=
'https://t%s.tianditu.gov.cn'
;
const
generateUrls
=
(
path
)
=>
{
return
services
.
map
((
v
)
=>
baseUrl
.
replace
(
'%s'
,
v
.
toString
())
+
path
);
};
// 天地图卫星影像服务地址
const
satellitePath
=
"/img_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="
+
tk
;
const
TDTSatelliteUrls
=
generateUrls
(
satellitePath
);
// 获取原始地图数据集合
const
dataServerPath
=
"/DataServer?T=img_w&x={x}&y={y}&l={z}&tk="
+
tk
;
const
TDTDataServerUrls
=
generateUrls
(
dataServerPath
);
// 天地图注记服务地址
const
annotationPath
=
"/cia_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk="
+
tk
;
const
TDTAnnotationUrls
=
generateUrls
(
annotationPath
);
return
{
TDTSatelliteUrls
,
TDTDataServerUrls
,
TDTAnnotationUrls
,
};
}
// mapbox的字体
const
glyphs
=
'mapbox://fonts/mapbox/{fontstack}/{range}.pbf'
;
// 获取地址
const
{
TDTDataServerUrls
,
TDTAnnotationUrls
,
TDTSatelliteUrls
}
=
getTDTUrls
();
// 构建样式
const
defaultStyle
=
{
version
:
8
,
sources
:
{
tianmap
:
{
type
:
'raster'
,
tiles
:
TDTSatelliteUrls
,
tileSize
:
256
,
attribution
:
'天地图影像图'
,
},
// 添加注记图层的数据源
tianmapAnnotation
:
{
type
:
'raster'
,
tiles
:
TDTAnnotationUrls
,
tileSize
:
256
,
attribution
:
'天地图注记图层'
,
},
},
layers
:
[
{
id
:
'tianmap-layer'
,
type
:
'raster'
,
source
:
'tianmap'
,
},
{
id
:
'tianmap-annotation-layer'
,
type
:
'raster'
,
source
:
'tianmapAnnotation'
,
},
],
// 添加 glyphs 属性到地图样式
glyphs
,
};
const
MyApp
=
defineComponent
({
const
MyApp
=
defineComponent
({
name
:
'MyApp'
,
name
:
'MyApp'
,
template
:
'#my-app'
,
template
:
'#my-app'
,
setup
()
{
setup
()
{
const
message
=
useMessage
()
const
message
=
useMessage
()
const
notification
=
useNotification
()
const
notification
=
useNotification
()
const
formRef
=
ref
(
null
)
const
mapContainer
=
ref
(
null
);
const
showModalRef
=
ref
(
false
)
let
map
=
ref
(
null
);
const
handleClick
=
()
=>
{
showModalRef
.
value
=
true
onMounted
(()
=>
{
}
if
(
mapContainer
.
value
)
{
return
{
// 确保容器已完全渲染
notify
(
type
)
{
setTimeout
(()
=>
{
notification
[
type
]({
map
.
value
=
new
mapboxgl
.
Map
({
content
:
'What to say?'
,
container
:
mapContainer
.
value
,
meta
:
'I don
\'
t know'
,
style
:
defaultStyle
,
duration
:
2500
,
center
:
[
116.404
,
39.915
],
keepAliveOnHover
:
true
zoom
:
11
,
})
minZoom
:
5
,
},
maxZoom
:
18
,
formRef
,
pitch
:
0
,
showModal
:
showModalRef
,
accessToken
:
mapBoxToken
,
handleClick
,
antialias
:
true
,
slide
:
ref
(
50
),
bearing
:
0
,
formValue
:
ref
({
interactive
:
true
,
user
:
{
attributionControl
:
false
,
name
:
''
,
});
age
:
''
},
// 添加resize事件监听器
phone
:
''
window
.
addEventListener
(
'resize'
,
()
=>
{
}),
map
.
value
.
resize
();
data
:
[
});
{
no
:
3
,
title
:
'Wonderwall'
,
length
:
'4:18'
},
{
no
:
4
,
title
:
'Don
\'
t Look Back in Anger'
,
length
:
'4:48'
},
// 添加地图控件
{
no
:
12
,
title
:
'Champagne Supernova'
,
length
:
'7:27'
}
map
.
value
.
addControl
(
new
mapboxgl
.
NavigationControl
());
],
},
0
);
pagination
:
ref
({
pageSize
:
5
}),
columns
:
[{
title
:
'No'
,
key
:
'no'
},
{
title
:
'Title'
,
key
:
'title'
},
{
title
:
'Length'
,
key
:
'length'
},
{
title
:
'Action'
,
key
:
'actions'
}],
rules
:
{
user
:
{
name
:
{
required
:
true
,
message
:
'Please input your name'
,
trigger
:
'blur'
},
age
:
{
required
:
true
,
message
:
'Please input your age'
,
trigger
:
[
'input'
,
'blur'
]
}
},
phone
:
{
required
:
true
,
message
:
'Please input your number'
,
trigger
:
[
'input'
]
}
},
handleValidateClick
(
e
)
{
e
.
preventDefault
()
formRef
.
value
?.
validate
((
errors
)
=>
{
if
(
!
errors
)
{
message
.
success
(
'Valid'
)
}
else
{
console
.
log
(
errors
)
message
.
error
(
'Invalid'
)
}
})
},
options
:
[
{
label
:
'滨海湾金沙,新加坡'
,
key
:
'marina bay sands'
,
disabled
:
true
},
{
label
:
'布朗酒店,伦敦'
,
key
:
'brown
\'
s hotel, london'
},
{
label
:
'亚特兰蒂斯巴哈马,拿骚'
,
key
:
'atlantis nahamas, nassau'
},
{
label
:
'比佛利山庄酒店,洛杉矶'
,
key
:
'the beverly hills hotel, los angeles'
}
],
handleSelect
(
key
)
{
message
.
info
(
String
(
key
))
}
}
});
return
{
mapContainer
}
}
}
}
})
})
// app.use(naive).mount('#app');
// const MyApp = defineComponent({
// name: 'MyApp',
// template: '#my-app-template',
// setup() {
// const message = useMessage()
// const buttonText = ref("点击我")
// const handleClick = () => {
// message.success("你点了按钮!")
// }
// return { buttonText, handleClick }
// }
// })
const
app
=
Vue
.
createApp
({})
const
app
=
Vue
.
createApp
({})
app
.
component
(
'my-app'
,
MyApp
)
app
.
component
(
'my-app'
,
MyApp
)
app
.
use
(
naive
)
app
.
use
(
naive
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment