提交 d2d12e33 作者: test

fix: 修复 Mapbox 组件设计调整后的相关使用变更

上级 198eb1d0
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar' import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar'
import { AffixFilterWidget, useAffixFilterWidget } from '@/components/Map/Widgets/AffixFilter' import { AffixFilterWidget, useAffixFilterWidget } from '@/components/Map/Widgets/AffixFilter'
import type { MapboxInstance } from '@/components/Map/Mapbox'
useShare() useShare()
...@@ -35,8 +34,8 @@ ...@@ -35,8 +34,8 @@
// 说明: 根据每个页面的 widget 布局情况,可能需要适当调整地图的中心位置,让界面显示效果更好 // 说明: 根据每个页面的 widget 布局情况,可能需要适当调整地图的中心位置,让界面显示效果更好
center: [111.6, 26.170844], center: [111.6, 26.170844],
}, },
onLoaded: (map: MapboxInstance, data: Recordable) => { onLoaded: (data: Recordable) => {
console.log('✨✨✨ Map Loaded', map, data) console.log('✨✨✨ Map Loaded', data)
Message.alert(JSON.stringify(data), '地图加载完成') Message.alert(JSON.stringify(data), '地图加载完成')
}, },
}) })
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { hourTemLegendConfig } from './config' import { hourTemLegendConfig } from './config'
import { useShare } from '@/hooks/page/useShare' import { useShare } from '@/hooks/page/useShare'
import { buildGeoJSONSourceDataUrl, useMapbox } from '@/components/Map/Mapbox/hook' import { useMapbox } from '@/components/Map/Mapbox/hook'
import { LegendWidget, useLegendWidget } from '@/components/Map/Widgets/Legend' import { LegendWidget, useLegendWidget } from '@/components/Map/Widgets/Legend'
import { SwitchWidget, useSwitchWidget } from '@/components/Map/Widgets/Switch' import { SwitchWidget, useSwitchWidget } from '@/components/Map/Widgets/Switch'
import { TimeBarWidget, formatTime, useTimeBarWidget } from '@/components/Map/Widgets/TimeBar' import { TimeBarWidget, formatTime, useTimeBarWidget } from '@/components/Map/Widgets/TimeBar'
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar' import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar'
import type { MapboxInstance, Station } from '@/components/Map/Mapbox' import type { Station } from '@/components/Map/Mapbox'
import { HandlerUtil } from '@/components/Map/Mapbox' import { HandlerUtil } from '@/components/Map/Mapbox'
useShare() useShare()
...@@ -20,29 +20,25 @@ ...@@ -20,29 +20,25 @@
// filter: {}, // filter: {},
// }) // })
const baseUrl = 'http://qks.straw.yiring.com:40051/tbm/api'
const token = `68b919d2-2ea0-4ad3-9521-9e624e1563ac`
// 地图组件 // 地图组件
const [registerMap, map] = useMapbox({ const [registerMap, map] = useMapbox({
style: { style: {
center: [111.6, 26.170844], center: [111.6, 26.170844],
}, },
onLoaded: (map: MapboxInstance, data: Recordable) => { onLoaded: () => {
console.log('✨✨✨ Map Loaded', map, data) console.log('✨✨✨ Map Loaded')
// 模拟色斑叠加数据源 // 模拟色斑叠加数据源
map.setGeoJSONSourceForRequest( map.setGeoJSONSourceForRequest(
'tem-splot', 'tem-splot',
buildGeoJSONSourceDataUrl({ {
url: `${baseUrl}/live/tem/getTemStain`, url: '/live/tem/getTemStain',
params: { params: {
stationType: 1, stationType: 1,
liveQueryType: 'ONE_HOUR_TEM', liveQueryType: 'ONE_HOUR_TEM',
Authorization: token,
}, },
}), },
(response) => response.body.jsonObject, (body) => body.jsonObject,
) )
// 模拟色斑叠加图层 // 模拟色斑叠加图层
...@@ -65,17 +61,16 @@ ...@@ -65,17 +61,16 @@
// 模拟数值叠加数据源 // 模拟数值叠加数据源
map.setGeoJSONSourceForRequest( map.setGeoJSONSourceForRequest(
'tem-text', 'tem-text',
buildGeoJSONSourceDataUrl({ {
url: `${baseUrl}/live/tem/getTemList`, url: '/live/tem/getTemList',
params: { params: {
stationType: 1, stationType: 1,
liveQueryType: 'ONE_HOUR_TEM', liveQueryType: 'ONE_HOUR_TEM',
Authorization: token,
}, },
}), },
// 此处使用 // 此处使用
(response) => { (body) => {
const features = response.body.liveVos.map((item: Station) => { const features = body.liveVos.map((item: Station) => {
item.key = '气温' item.key = '气温'
item.suffix = '°C' item.suffix = '°C'
return HandlerUtil.createDefaultPointFeature(item) return HandlerUtil.createDefaultPointFeature(item)
...@@ -107,6 +102,11 @@ ...@@ -107,6 +102,11 @@
map.on('click', 'tem-text', function (e) { map.on('click', 'tem-text', function (e) {
console.log('🚀🚀🚀', e) console.log('🚀🚀🚀', e)
}) })
console.log('✨✨✨ Map Loaded End')
},
onSourceRequestHandle: (data) => {
console.log('✨✨✨ Map onSourceRequestHandle', data)
}, },
}) })
......
...@@ -3,18 +3,16 @@ ...@@ -3,18 +3,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { hourTemLegendConfig, windheaderData, windtableData } from './config' import { hourTemLegendConfig, windheaderData, windtableData } from './config'
import { useShare } from '@/hooks/page/useShare' import { useShare } from '@/hooks/page/useShare'
import { buildGeoJSONSourceDataUrl, useMapbox } from '@/components/Map/Mapbox/hook' import { useMapbox } from '@/components/Map/Mapbox/hook'
import { LegendWidget, useLegendWidget } from '@/components/Map/Widgets/Legend' import { LegendWidget, useLegendWidget } from '@/components/Map/Widgets/Legend'
import { SwitchWidget, useSwitchWidget } from '@/components/Map/Widgets/Switch' import { SwitchWidget, useSwitchWidget } from '@/components/Map/Widgets/Switch'
import { TimeBarWidget, formatTime, useTimeBarWidget } from '@/components/Map/Widgets/TimeBar' import { TimeBarWidget, formatTime, useTimeBarWidget } from '@/components/Map/Widgets/TimeBar'
import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox' import { ToolBoxWidget, useToolBoxWidget } from '@/components/Map/Widgets/ToolBox'
import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar' import { BottomBarWidget, useBottomBarWidget } from '@/components/Map/Widgets/BottomBar'
import type { MapboxInstance, Station } from '@/components/Map/Mapbox' import type { Station } from '@/components/Map/Mapbox'
import { HandlerUtil } from '@/components/Map/Mapbox' import { HandlerUtil } from '@/components/Map/Mapbox'
import { useGlobSetting } from '/@/hooks/setting'
useShare() useShare()
const globSetting = useGlobSetting()
// 页面参数 // 页面参数
const param = reactive({ const param = reactive({
query: { query: {
...@@ -67,31 +65,26 @@ ...@@ -67,31 +65,26 @@
} }
return toRaw(params) return toRaw(params)
} */ } */
const baseUrl = `${globSetting.apiUrl}${globSetting.urlPrefix}`
// const token = `68b919d2-2ea0-4ad3-9521-9e624e1563ac`
const token = `8b218589-12cf-4de2-9f62-b00a5dfcab82`
// 地图组件 // 地图组件
// const [registerMap, map] = useMapbox({ // const [registerMap, map] = useMapbox({
const [registerMap, { setGeoJSONSourceData }, map] = useMapbox({ const [registerMap, map] = useMapbox({
style: { style: {
center: [111.6, 26.170844], center: [111.6, 26.170844],
}, },
onLoaded: (map: MapboxInstance, data: Recordable) => { onLoaded: (data: Recordable) => {
console.log('✨✨✨ Map Loaded', map, data) console.log('✨✨✨ Map Loaded', map, data)
// 模拟色斑叠加数据源 // 模拟色斑叠加数据源
map.setGeoJSONSourceForRequest( map.setGeoJSONSourceForRequest(
'wind-splot', 'wind-splot',
buildGeoJSONSourceDataUrl({ {
// url: `${baseUrl}/live/tem/getTemStain`, url: `/live/wind/getWindStain`,
url: `${baseUrl}/live/wind/getWindStain`,
params: { params: {
stationType: 1, stationType: 1,
liveQueryType: 'TWO_MINUTES_WIND', liveQueryType: 'TWO_MINUTES_WIND',
Authorization: token,
}, },
}), },
(response) => response.body.jsonObject, (body) => body.jsonObject,
) )
// 模拟色斑叠加图层 // 模拟色斑叠加图层
...@@ -114,17 +107,16 @@ ...@@ -114,17 +107,16 @@
// 模拟数值叠加数据源 // 模拟数值叠加数据源
map.setGeoJSONSourceForRequest( map.setGeoJSONSourceForRequest(
'wind-text', 'wind-text',
buildGeoJSONSourceDataUrl({ {
url: `${baseUrl}/live/wind/getWindList`, url: `/live/wind/getWindList`,
params: { params: {
stationType: 1, stationType: 1,
liveQueryType: 'TWO_MINUTES_WIND', liveQueryType: 'TWO_MINUTES_WIND',
Authorization: token,
}, },
}), },
// 此处使用 // 此处使用
(response) => { (body) => {
const features = response.body.liveVos.map((item: Station) => { const features = body.liveVos.map((item: Station) => {
item.key = '风速' item.key = '风速'
item.suffix = 'm/s' item.suffix = 'm/s'
return HandlerUtil.createDefaultPointFeature(item) return HandlerUtil.createDefaultPointFeature(item)
...@@ -159,12 +151,6 @@ ...@@ -159,12 +151,6 @@
}, },
}) })
function clickTest() { function clickTest() {
console.log('setGeoJSONSourceData', setGeoJSONSourceData)
setGeoJSONSourceData('wind-splot', {
type: 'FeatureCollection',
features: [],
})
param.minmaxData = [ param.minmaxData = [
{ label: '最大风速', value: '99m/s' }, { label: '最大风速', value: '99m/s' },
{ label: '平均风速', value: '28m/s' }, { label: '平均风速', value: '28m/s' },
...@@ -326,7 +312,7 @@ ...@@ -326,7 +312,7 @@
// 当底部 Bar 小部件高度变化时,重新设置地图的中心点,使界面显示效果更好 // 当底部 Bar 小部件高度变化时,重新设置地图的中心点,使界面显示效果更好
if (map?.isReady?.value) { if (map?.isReady?.value) {
if (value === '210rpx') { if (value === 220) {
map.flyTo({ map.flyTo({
center: [111.6, 26.770844], center: [111.6, 26.770844],
speed: 0.2, speed: 0.2,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论