|
@@ -217,6 +217,9 @@ export default class VideoOverview extends Vue {
|
|
|
currentPage = 1
|
|
|
|
|
|
timer = null
|
|
|
+
|
|
|
+ currentZoomLevel = null //当前地图缩放级别
|
|
|
+ cameraDataSourceList = []
|
|
|
//computed
|
|
|
get playicon() {
|
|
|
return require('../images/playicon.png')
|
|
@@ -234,12 +237,19 @@ export default class VideoOverview extends Vue {
|
|
|
this.cameraShowList.push(this.cameraList.slice(i, i + 3))
|
|
|
}
|
|
|
}
|
|
|
+ @Watch('cameraDataSourceList')
|
|
|
+ onCamearDsChange() {
|
|
|
+ if (this.cameraDataSourceList.length == this.cameraList.length) {
|
|
|
+ this.changeShowType()
|
|
|
+ }
|
|
|
+ }
|
|
|
get mapView() {
|
|
|
return (this.$attrs.data as any).mapView
|
|
|
}
|
|
|
@Watch('mapView', { immediate: true })
|
|
|
onChangeMethod(val) {
|
|
|
this.debounce(() => {
|
|
|
+ this.currentZoomLevel = this.mapView.getView().getZoom()
|
|
|
this.getCameraType()
|
|
|
this.initMapTool()
|
|
|
}, 300)()
|
|
@@ -279,6 +289,7 @@ export default class VideoOverview extends Vue {
|
|
|
this.isSearchCompleted = true
|
|
|
this.originalData = result
|
|
|
this.initialDisplay(result, true)
|
|
|
+ this.zoomAndMove()
|
|
|
}
|
|
|
|
|
|
//初始显示
|
|
@@ -408,7 +419,11 @@ export default class VideoOverview extends Vue {
|
|
|
const data = emitData
|
|
|
let position = [data.longitude || 0, data.latitude || 0]
|
|
|
const dataSource = { ...data, position: position.map((i) => Number(i)), src: img }
|
|
|
- this.isShowAllSites ? this.mapTool.showPointSymbol(dataSource) : this.mapTool.located(dataSource, true)
|
|
|
+ if (this.isShowAllSites) {
|
|
|
+ this.cameraDataSourceList.push(dataSource)
|
|
|
+ } else {
|
|
|
+ this.mapTool.located(dataSource, true)
|
|
|
+ }
|
|
|
}
|
|
|
//获取长度
|
|
|
getAllChildLength(node) {
|
|
@@ -442,7 +457,8 @@ export default class VideoOverview extends Vue {
|
|
|
}
|
|
|
//展示视频点
|
|
|
mapShowSite(sites) {
|
|
|
- this.mapTool.vectorLayer.getSource().clear()
|
|
|
+ this.mapTool.clear()
|
|
|
+ this.cameraDataSourceList = []
|
|
|
this.isShowAllSites = true
|
|
|
;(async () => {
|
|
|
for (let index = 0; index < sites.length; index++) {
|
|
@@ -492,11 +508,69 @@ export default class VideoOverview extends Vue {
|
|
|
this.detailsData = null
|
|
|
this.mapTool.select.getFeatures().clear()
|
|
|
}
|
|
|
+ // 开启缩放和拖动
|
|
|
+ zoomAndMove() {
|
|
|
+ //地图缩放和平移事件回调函数
|
|
|
+ let mapZoomAndMove = () => {
|
|
|
+ this.changeShowType()
|
|
|
+ }
|
|
|
+ //注册事件
|
|
|
+ this.registerOnZoom(mapZoomAndMove)
|
|
|
+ }
|
|
|
+ //地图缩放监听
|
|
|
+ registerOnZoom(eventListen, notListenMove?) {
|
|
|
+ let map = this.mapView
|
|
|
+ // 记录地图缩放,用于判断拖动
|
|
|
+ map.lastZoom = map.lastZoom || map.getView().getZoom()
|
|
|
+ // 地图缩放事件
|
|
|
+ let registerOnZoom = function (e) {
|
|
|
+ // 不监听地图拖动事件
|
|
|
+ if (notListenMove) {
|
|
|
+ if (map.lastZoom != map.getView().getZoom()) {
|
|
|
+ eventListen && eventListen(e)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ eventListen && eventListen(e)
|
|
|
+ }
|
|
|
+ map.lastZoom = map.getView().getZoom()
|
|
|
+ }
|
|
|
+ // 保存缩放和拖动事件对象,用于后期移除
|
|
|
+ let registerOnZoomArr = map.get('registerOnZoom') || []
|
|
|
+ registerOnZoomArr.push(registerOnZoom)
|
|
|
+ // 使用地图 set 方法保存事件对象
|
|
|
+ map.set('registerOnZoom', registerOnZoomArr)
|
|
|
+ // 监听地图移动结束事件
|
|
|
+ map.on('moveend', registerOnZoom)
|
|
|
+ return eventListen
|
|
|
+ }
|
|
|
+ // 移除缩放和拖动事件对象
|
|
|
+ removeZoomRegister() {
|
|
|
+ let map = this.mapView
|
|
|
+ let registerOnZoomArr = map.get('registerOnZoom')
|
|
|
+ if (registerOnZoomArr && registerOnZoomArr.length > 0) {
|
|
|
+ for (let i = 0; i < registerOnZoomArr.length; i++) {
|
|
|
+ map.un('moveend', registerOnZoomArr[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //聚合展示还是图标展示
|
|
|
+ changeShowType() {
|
|
|
+ this.currentZoomLevel = this.mapView.getView().getZoom()
|
|
|
+ this.mapTool.clear()
|
|
|
+ if (this.currentZoomLevel < 18) {
|
|
|
+ this.mapTool.showClusterPoint(this.cameraDataSourceList)
|
|
|
+ } else {
|
|
|
+ this.cameraDataSourceList.forEach((item) => {
|
|
|
+ this.mapTool.showPointSymbol(item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
beforeDestroy() {
|
|
|
if (this.mapTool) this.mapTool.destroy()
|
|
|
this.dialogVisible = false
|
|
|
this.checkSite = null
|
|
|
this.detailsData = null
|
|
|
+ this.removeZoomRegister()
|
|
|
}
|
|
|
}
|
|
|
</script>
|