Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
722ce2cd
提交
722ce2cd
authored
8月 22, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 实现气温模块的色斑和数值叠加显示效果
上级
1fa947a8
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
100 行增加
和
2 行删除
+100
-2
index.vue
src/pages/business/monitor/tem/index.vue
+100
-2
没有找到文件。
src/pages/business/monitor/tem/index.vue
浏览文件 @
722ce2cd
...
...
@@ -3,13 +3,14 @@
<
script
setup
lang=
"ts"
>
import
{
hourTemLegendConfig
}
from
'./config'
import
{
useShare
}
from
'@/hooks/page/useShare'
import
{
useMapbox
}
from
'@/components/Map/Mapbox/hook'
import
{
buildGeoJSONSourceDataUrl
,
useMapbox
}
from
'@/components/Map/Mapbox/hook'
import
{
LegendWidget
,
useLegendWidget
}
from
'@/components/Map/Widgets/Legend'
import
{
SwitchWidget
,
useSwitchWidget
}
from
'@/components/Map/Widgets/Switch'
import
{
TimeBarWidget
,
formatTime
,
useTimeBarWidget
}
from
'@/components/Map/Widgets/TimeBar'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
{
BottomBarWidget
,
useBottomBarWidget
}
from
'@/components/Map/Widgets/BottomBar'
import
type
{
MapboxInstance
}
from
'@/components/Map/Mapbox'
import
{
HandlerUtil
}
from
'@/components/Map/Mapbox'
useShare
()
...
...
@@ -19,13 +20,93 @@
// filter: {},
// })
const
baseUrl
=
'http://qks.straw.yiring.com:40051/tbm/api'
const
token
=
`68b919d2-2ea0-4ad3-9521-9e624e1563ac`
// 地图组件
const
[
registerMap
]
=
useMapbox
({
const
[
registerMap
,
map
]
=
useMapbox
({
style
:
{
center
:
[
111.6
,
26.170844
],
},
onLoaded
:
(
map
:
MapboxInstance
,
data
:
Recordable
)
=>
{
console
.
log
(
'✨✨✨ Map Loaded'
,
map
,
data
)
// 模拟色斑叠加数据源
map
.
setGeoJSONSourceForRequest
(
'tem-splot'
,
buildGeoJSONSourceDataUrl
({
url
:
`
${
baseUrl
}
/live/tem/getTemStain`
,
params
:
{
stationType
:
1
,
liveQueryType
:
'ONE_HOUR_TEM'
,
Authorization
:
token
,
},
}),
(
response
)
=>
response
.
body
.
jsonObject
,
)
// 模拟色斑叠加图层
map
.
addLayer
(
{
id
:
'tem-splot'
,
type
:
'fill'
,
source
:
'tem-splot'
,
paint
:
{
'fill-color'
:
{
type
:
'identity'
,
property
:
'color'
,
},
'fill-opacity'
:
1
,
},
},
'fill-placeholder'
,
)
// 模拟数值叠加数据源
map
.
setGeoJSONSourceForRequest
(
'tem-text'
,
buildGeoJSONSourceDataUrl
({
url
:
`
${
baseUrl
}
/live/tem/getTemList`
,
params
:
{
stationType
:
1
,
liveQueryType
:
'ONE_HOUR_TEM'
,
Authorization
:
token
,
},
}),
// 此处使用
(
response
)
=>
{
const
features
=
response
.
body
.
liveVos
.
map
(
function
(
item
)
{
item
.
key
=
'气温'
item
.
suffix
=
'°C'
return
HandlerUtil
.
createDefaultGeoJSONFeatureData
(
item
)
})
return
HandlerUtil
.
createDefaultGeoJSONSymbolSourceData
(
features
)
},
)
// 模拟数值叠加图层
map
.
addLayer
({
id
:
'tem-text'
,
type
:
'symbol'
,
source
:
'tem-text'
,
layout
:
{
'text-field'
:
'{value}'
,
'text-size'
:
14
,
'text-offset'
:
[
0
,
1.2
],
'icon-image'
:
'point.normal'
,
'icon-anchor'
:
'top'
,
'icon-size'
:
0.4
,
},
paint
:
{
'text-color'
:
'#3766fd'
,
'text-halo-color'
:
'#fff'
,
'text-halo-width'
:
1
,
},
})
map
.
on
(
'click'
,
'tem-text'
,
function
(
e
)
{
console
.
log
(
'🚀🚀🚀'
,
e
)
})
},
})
...
...
@@ -167,6 +248,23 @@
setSwitchProps
({
bottom
:
value
})
setLegendProps
({
bottom
:
value
})
setToolBoxProps
({
bottom
:
value
})
// 当底部 Bar 小部件高度变化时,重新设置地图的中心点,使界面显示效果更好
if
(
map
.
isReady
.
value
)
{
if
(
value
===
'210rpx'
)
{
map
.
flyTo
({
center
:
[
111.6
,
26.770844
],
speed
:
0.2
,
essential
:
true
,
})
}
else
{
map
.
flyTo
({
center
:
[
111.6
,
26.170844
],
speed
:
0.2
,
essential
:
true
,
})
}
}
},
)
</
script
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论