Commit 436214d611f398be67f561e6fca0314796a2201a
Merge branch 'fix/save-thumb' into 'main_dev'
fix: 修复设备分布地图保存缩略图时为空白地图 See merge request yunteng/thingskit-view!142
Showing
2 changed files
with
37 additions
and
24 deletions
... | ... | @@ -56,7 +56,10 @@ const initMap = (newData: any) => { |
56 | 56 | pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度 |
57 | 57 | skyColor: skyColor.value, |
58 | 58 | viewMode: viewMode.value, // 地图模式 |
59 | - willReadFrequently: true | |
59 | + willReadFrequently: true, | |
60 | + WebGLParams: { | |
61 | + preserveDrawingBuffer: true, | |
62 | + } | |
60 | 63 | }) |
61 | 64 | dataHandle(props.chartConfig.option.dataset) |
62 | 65 | let satellite = new AMap.TileLayer.Satellite() |
... | ... | @@ -68,7 +71,7 @@ const initMap = (newData: any) => { |
68 | 71 | mapIns.setMapStyle(`amap://styles/${amapStyleKeyCustom.value !== '' ? amapStyleKeyCustom.value : amapStyleKey.value}`) |
69 | 72 | } |
70 | 73 | }) |
71 | - .catch(e => {}) | |
74 | + .catch(e => { }) | |
72 | 75 | } |
73 | 76 | |
74 | 77 | const dataHandle = (newData: any) => { | ... | ... |
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | </template> |
6 | 6 | |
7 | 7 | <script setup lang="ts"> |
8 | -import { ref, PropType, toRefs, watch, render, h, onMounted, onUnmounted, reactive} from 'vue' | |
8 | +import { ref, PropType, toRefs, watch, render, h, onMounted, onUnmounted, reactive } from 'vue' | |
9 | 9 | import AMapLoader from '@amap/amap-jsapi-loader' |
10 | 10 | import { CreateComponentType } from '@/packages/index.d' |
11 | 11 | import { useChartDataFetch } from '@/hooks' |
... | ... | @@ -74,7 +74,10 @@ const initMap = (newData: any) => { |
74 | 74 | pitch: pitch.value, // 地图俯仰角度,有效范围 0 度- 83 度 |
75 | 75 | skyColor: skyColor.value, |
76 | 76 | viewMode: viewMode.value, // 地图模式 |
77 | - willReadFrequently: true | |
77 | + willReadFrequently: true, | |
78 | + WebGLParams: { | |
79 | + preserveDrawingBuffer: true, | |
80 | + } | |
78 | 81 | }) |
79 | 82 | dataHandle(props.chartConfig.option.dataset) //处理地图标点 |
80 | 83 | let satellite = new AMap.TileLayer.Satellite() |
... | ... | @@ -99,10 +102,10 @@ const initMap = (newData: any) => { |
99 | 102 | |
100 | 103 | //携带设备的tbDeviceId和别名或者名称 |
101 | 104 | const devicePartInfo = reactive<devicePartInfoInterface>({ |
102 | - tbDeviceId:'', | |
103 | - name:'', | |
104 | - alias:'', | |
105 | - deviceProfileId:'', | |
105 | + tbDeviceId: '', | |
106 | + name: '', | |
107 | + alias: '', | |
108 | + deviceProfileId: '', | |
106 | 109 | }) |
107 | 110 | |
108 | 111 | //创建信息弹窗 |
... | ... | @@ -137,25 +140,24 @@ const createInfoWindow = async (extraInfo: dataExtraInfoType) => { |
137 | 140 | <div style="display:flex;flex-direction:column;margin:3.5rem 5.5rem 2rem 6.5rem;position:relative;"> |
138 | 141 | <div style="display:flex;justify-content:space-between;align-items:center;color:white;"> |
139 | 142 | <span style="${textOverflowFontBold}">${alias || name}</span> |
140 | - ${ | |
141 | - deviceState === 'INACTIVE' | |
142 | - ? `<div style="${deviceStateContainer}"> | |
143 | + ${deviceState === 'INACTIVE' | |
144 | + ? `<div style="${deviceStateContainer}"> | |
143 | 145 | <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> |
144 | 146 | <img style="${deviceStateImg};margin-left:0.3rem" src="${inactive}"/> |
145 | 147 | <span style="${deviceStateText}">待激活</span> |
146 | 148 | </div>` |
147 | - : deviceState === 'ONLINE' | |
148 | - ? `<div style="${deviceStateContainer}"> | |
149 | + : deviceState === 'ONLINE' | |
150 | + ? `<div style="${deviceStateContainer}"> | |
149 | 151 | <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> |
150 | 152 | <img style="${deviceStateImg};margin-left:0.3rem" src="${online}"/> |
151 | 153 | <span style="${deviceStateText}">在线</span> |
152 | 154 | </div>` |
153 | - : `<div style="${deviceStateContainer}"> | |
155 | + : `<div style="${deviceStateContainer}"> | |
154 | 156 | <img onclick="handleOpenDrawer()" title="最新数据" style="${deviceStateImg};cursor:pointer;" src="${listView}"/> |
155 | 157 | <img style="${deviceStateImg};margin-left:0.3rem" src="${offline}"/> |
156 | 158 | <span style="${deviceStateText}">离线</span> |
157 | 159 | </div>` |
158 | - } | |
160 | + } | |
159 | 161 | </div> |
160 | 162 | <div style="display:flex;flex-direction:column;justify-content:space-between;color:white;margin-top:1rem;gap:0.95rem;"> |
161 | 163 | <div style="${textOverflow}">所属组织:${organizationDTO.name}</div> |
... | ... | @@ -176,16 +178,16 @@ const handleOpenDrawer = async () => { |
176 | 178 | deviceLatestTableRef.value?.setDrawerTitle(devicePartInfo.alias || devicePartInfo.name) |
177 | 179 | if (!devicePartInfo.tbDeviceId) return |
178 | 180 | const resp = await getDeviceLatest(devicePartInfo.tbDeviceId) |
179 | - const respGetAttrs = await getProfileAttrs({deviceProfileId: devicePartInfo.deviceProfileId}) | |
180 | - deviceLatestTableRef.value?.setValue(resp,respGetAttrs) | |
181 | + const respGetAttrs = await getProfileAttrs({ deviceProfileId: devicePartInfo.deviceProfileId }) | |
182 | + deviceLatestTableRef.value?.setValue(resp, respGetAttrs) | |
181 | 183 | } |
182 | 184 | |
183 | 185 | onMounted(() => { |
184 | - (window as any).handleOpenDrawer = handleOpenDrawer; | |
186 | + (window as any).handleOpenDrawer = handleOpenDrawer; | |
185 | 187 | }); |
186 | 188 | |
187 | 189 | onUnmounted(() => { |
188 | - (window as any).handleOpenDrawer = null; | |
190 | + (window as any).handleOpenDrawer = null; | |
189 | 191 | }); |
190 | 192 | |
191 | 193 | //地图鼠标hover |
... | ... | @@ -225,9 +227,10 @@ const dataHandle = (newData: dataJsonType) => { |
225 | 227 | offset: new AMapIns.Pixel(-13, 5), |
226 | 228 | icon: iconMarker.value |
227 | 229 | }) |
228 | - // markers.push(markerInstance) 原作者这种方式添加,属于JS API 1.4.8版本的 | |
229 | - // markerInstance.setMap(mapIns) | |
230 | - mapIns.add(markerInstance) | |
230 | + // 原作者这种方式添加,属于JS API 1.4.8版本的 | |
231 | + markers.push(markerInstance) | |
232 | + markerInstance.setMap(mapIns) | |
233 | + // mapIns.add(markerInstance) | |
231 | 234 | mapClick(markerInstance, markerItem) |
232 | 235 | }) |
233 | 236 | } else if (mapMarkerType.value === MarkerEnum.CIRCLE_MARKER) { |
... | ... | @@ -285,18 +288,23 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { |
285 | 288 | |
286 | 289 | <style> |
287 | 290 | /**去除高德地图原生弹窗 */ |
288 | -.amap-info-outer, .amap-menu-outer { | |
289 | - box-shadow: 0 1px 2px rgba(0,0,0,0)!important; | |
291 | +.amap-info-outer, | |
292 | +.amap-menu-outer { | |
293 | + box-shadow: 0 1px 2px rgba(0, 0, 0, 0) !important; | |
290 | 294 | } |
295 | + | |
291 | 296 | .amap-info-outer { |
292 | 297 | background-color: rgba(0, 0, 0, 0) !important; |
293 | 298 | } |
299 | + | |
294 | 300 | .amap-info-close { |
295 | 301 | display: none !important; |
296 | 302 | } |
303 | + | |
297 | 304 | .amap-info-content { |
298 | 305 | overflow: hidden !important; |
299 | 306 | } |
307 | + | |
300 | 308 | /**去除高德地图原生弹窗*/ |
301 | 309 | .amap-info-content .go-border-box { |
302 | 310 | position: absolute; |
... | ... | @@ -304,6 +312,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { |
304 | 312 | top: 0; |
305 | 313 | z-index: -100; |
306 | 314 | } |
315 | + | |
307 | 316 | .amap-info-content .go-border-box svg { |
308 | 317 | background-color: v-bind(bgColor); |
309 | 318 | } |
... | ... | @@ -311,6 +320,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: any) => { |
311 | 320 | <style lang="scss" scoped> |
312 | 321 | .chart-amap { |
313 | 322 | position: relative; |
323 | + | |
314 | 324 | .search-box { |
315 | 325 | cursor: pointer; |
316 | 326 | position: absolute; | ... | ... |