Commit 77c292e48e5852aebbdf25253231ac4772294be6
1 parent
2eea791a
fix: DEFECT-1397 修复地理位置设备没有坐标,原因没有进行容错处理,服务端没有返回deviceInfo
Showing
1 changed file
with
19 additions
and
21 deletions
| ... | ... | @@ -304,27 +304,25 @@ |
| 304 | 304 | unref(BMapInstance)?.clearOverlays(); |
| 305 | 305 | const markerList: MarkerList[] = []; |
| 306 | 306 | data.forEach((item) => { |
| 307 | - const { | |
| 308 | - alias, | |
| 309 | - name, | |
| 310 | - deviceState, | |
| 311 | - deviceInfo: { longitude, latitude }, | |
| 312 | - } = item; | |
| 313 | - const point = new BMap.Point(longitude, latitude); | |
| 314 | - const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx; | |
| 315 | - const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30)); | |
| 316 | - const marker = new BMap.Marker(point, { icon: myIcon }); | |
| 317 | - const label = new BMap.Label(alias || name, { | |
| 318 | - position: point, | |
| 319 | - offset: new BMap.Size(-15, -45), | |
| 320 | - }); | |
| 321 | - label.setStyle({ | |
| 322 | - color: '#000', | |
| 323 | - borderRadius: '5px', | |
| 324 | - borderColor: '#ccc', | |
| 325 | - padding: '5px', | |
| 326 | - }); | |
| 327 | - markerList.push({ ...item, marker, label }); | |
| 307 | + const { alias, name, deviceState, deviceInfo } = item; | |
| 308 | + if (deviceInfo) { | |
| 309 | + const { longitude, latitude } = deviceInfo; | |
| 310 | + const point = new BMap.Point(longitude, latitude); | |
| 311 | + const rivet = deviceState === 'INACTIVE' ? djx : deviceState === 'ONLINE' ? zx : lx; | |
| 312 | + const myIcon = new BMap.Icon(rivet, new BMap.Size(20, 30)); | |
| 313 | + const marker = new BMap.Marker(point, { icon: myIcon }); | |
| 314 | + const label = new BMap.Label(alias || name, { | |
| 315 | + position: point, | |
| 316 | + offset: new BMap.Size(-15, -45), | |
| 317 | + }); | |
| 318 | + label.setStyle({ | |
| 319 | + color: '#000', | |
| 320 | + borderRadius: '5px', | |
| 321 | + borderColor: '#ccc', | |
| 322 | + padding: '5px', | |
| 323 | + }); | |
| 324 | + markerList.push({ ...item, marker, label }); | |
| 325 | + } | |
| 328 | 326 | }); |
| 329 | 327 | |
| 330 | 328 | markerList.forEach((record) => { | ... | ... |