<template>
|
<public-box class="public-org-nav-bar">
|
<template slot="public-box-header">
|
<div class="title">
|
<img class="icon deblurring" :src="headerLog" alt />
|
<span>{{ title }}</span>
|
</div>
|
<img class="close deblurring" :src="publicPath + 'img/navicon/close.png'" alt @click="closeModel" />
|
</template>
|
<template slot="public-box-content">
|
<!-- <div class="tab" v-show="false">
|
<ul>
|
<li :class="{ on: item.flag }" v-for="(item, index) in titleList" :key="index"
|
@click="topNavClick(item, index)">{{ item.title }}</li>
|
</ul>
|
</div> -->
|
<ul>
|
<li v-for="(item, index) in itemNavList" :key="index" @click="mapPopup(item.details)">
|
<img :src="item.icon" alt />
|
<span>{{ item.navTitle }}</span>
|
</li>
|
</ul>
|
</template>
|
</public-box>
|
</template>
|
|
<script>
|
import { mapGetters } from 'vuex'
|
import { getList, getLifeList } from '@/api/pc/service/index'
|
|
import VectorLayer from "ol/layer/Vector"
|
import VectorSource from "ol/source/Vector"
|
import Feature from 'ol/Feature.js'
|
import Point from 'ol/geom/Point.js'
|
import { Icon, Style, Fill, Text, Stroke } from 'ol/style.js'
|
|
let ourLayer = null
|
|
export default {
|
name: 'ServiceNavBar',
|
|
data () {
|
return {
|
publicPath: process.env.BASE_URL,
|
map2D: this.$store.state.openlayerData.openlayers.map2D,
|
itemNavList: []
|
}
|
},
|
|
inject: ["layoutElement"],
|
|
props: {
|
title: {
|
type: String
|
},
|
headerLog: {
|
type: String
|
},
|
arcCode: {
|
type: Number
|
}
|
},
|
computed: {
|
...mapGetters([
|
'popupBgUrl',
|
'pupupQRUrl',
|
// 点信息
|
'pointPosition',
|
// 点名称
|
'stateName',
|
// 地址
|
'siteName',
|
// 介绍
|
'introduceText',
|
// 全景地址
|
'panoramaUrl',
|
'twoOrThree'
|
])
|
},
|
created () {
|
// this.titleList = []
|
// 三江社区//"土木楼"//"科学园"//"黄河路"//"红旗社区"
|
// getList().then((res) => {
|
// res.data.data.forEach((item) => {
|
// // console.log(item, "see");
|
// this.titleList.push({
|
// title: item.dictValue,
|
// flag: false,
|
// key: item.dictKey
|
// })
|
// })
|
|
// this.titleList[0].flag = true
|
|
// })
|
},
|
watch: {
|
twoOrThree: {
|
handler (newData, oldData) {
|
|
},
|
immediate: true
|
}
|
},
|
mounted () {
|
|
this.getChilsNavs(this.layoutElement.campusValue)
|
|
},
|
methods: {
|
coordinate (item) {
|
const arr = item.split(',')
|
|
return {
|
lng: arr[0],
|
lat: arr[1]
|
}
|
},
|
closeModel () {
|
this.$parent.closeModel()
|
},
|
topNavClick (item, index) {
|
this.titleList.forEach((item) => {
|
item.flag = false
|
})
|
|
this.titleList[index].flag = true
|
|
this.getChilsNavs(item.key)
|
},
|
getChilsNavs (campus) {
|
this.itemNavList = []
|
const that = this
|
// console.log(this.arcCode, "see22");
|
// 判断是否是当前所需要图层并创建 属性为 this.arrCode
|
if (ourLayer != null) {
|
ourLayer.getSource().clear()
|
} else {
|
ourLayer = new VectorLayer({
|
// 图标图层
|
zIndex: 9,
|
source: new VectorSource(),
|
})
|
this.map2D.addLayer(ourLayer)
|
}
|
|
getLifeList({ lifetype: this.arcCode, campus: campus }).then((res) => {
|
this.$EventBus.$emit('closeTagLayer')
|
|
res.data.data.records.forEach((item) => {
|
// console.log(item, "see");
|
this.itemNavList.push({
|
navTitle: item.mechanismname,
|
icon: '/changjing/img/navicon/tag.png',
|
details: item
|
})
|
// 创建图标 做生活设施分层标签
|
that.addDivIcon(item, ourLayer)
|
})
|
})
|
},
|
addDivIcon (item, mylayer) {
|
const that = this
|
let obj = {}
|
|
if (item.x && item.x != '') {
|
const position = this.coordinate(item.x)
|
obj = {
|
lng: position.lng, lat: position.lat
|
}
|
} else {
|
obj = {
|
lng: item.jd, lat: item.wd
|
}
|
}
|
|
let siteJd = null
|
let siteWd = null
|
|
if (this.twoOrThree == '三 维') {
|
siteJd = obj.lng
|
siteWd = obj.lat
|
} else {
|
siteJd = item.jd
|
siteWd = item.wd
|
}
|
|
mylayer.getSource().addFeature(that.getCurItemFeature({
|
imgSize: [44, 44],
|
lng: siteJd,
|
lat: siteWd,
|
item,
|
text: item.mechanismname,
|
url: '/changjing/img/icon/bubble.png',
|
anchor: [16, 34],
|
event: (e) => {
|
that.mapPopup(item)
|
}
|
}))
|
},
|
|
getCurItemFeature (params) {
|
const iconFeature = new Feature({
|
geometry: new Point([Number(params.lng), Number(params.lat)]),
|
attributes: params.item
|
})
|
|
var textElement = document.createElement('span')
|
textElement.innerHTML = params.text
|
|
iconFeature.setStyle(new Style({
|
image: new Icon({
|
scale: params.scale || 1,
|
imgSize: params.imgSize || [30, 30],
|
src: params.url,
|
// 设置图标偏移
|
anchor: params.anchor,
|
// X方向单位:分数
|
anchorXUnits: 'pixels',
|
// Y方向单位:像素
|
anchorYUnits: 'pixels',
|
}),
|
|
text: new Text({
|
// 对齐方式
|
textAlign: 'center',
|
// 文本基线
|
textBaseline: 'middle',
|
text: textElement.innerHTML,
|
font: '14px Arial',
|
fill: new Fill({
|
color: '#351FAD'
|
}),
|
stroke: new Stroke({ color: 'white', width: 1 })
|
})
|
}))
|
|
let featureEvent
|
|
if (params.event) {
|
featureEvent = params.event
|
} else {
|
featureEvent = () => { }
|
}
|
|
iconFeature.on('click', featureEvent)
|
|
return iconFeature
|
},
|
|
mapPopup (param) {
|
let obj = {}
|
|
if (param.x && param.x != '') {
|
const position = this.coordinate(param.x)
|
obj = {
|
lng: position.lng, lat: position.lat
|
}
|
} else {
|
obj = {
|
lng: param.jd, lat: param.wd
|
}
|
}
|
|
var result = param
|
this.$store.commit('CLEAR_ALL', null)
|
|
var imgArr = result.tpurl.split(',')
|
|
this.$store.commit('SET_POPUPBGURL', imgArr[0])
|
this.$store.commit('SET_POPUPQRURL', result.codeurl)
|
|
this.map2D.getView().setCenter([Number(obj.lng), Number(obj.lat)])
|
|
this.$store.commit('SET_STATENAME', result.mechanismname)
|
this.$store.commit('SET_SITENAME', result.address)
|
this.$store.commit('SET_TELEPHONE', result.telephone)
|
this.$store.commit('SET_INTRODUCETEXT', result.introduce)
|
this.$store.commit('SET_PANORAMAURL', result.panoramaurl)
|
this.$store.commit('SET_POPUPIMGATLAS', imgArr)
|
|
if (result.videourl && result.videourl != '') {
|
this.$store.commit('SET_MONITORURL', result.videourl)
|
}
|
|
this.newPopup(result, obj)
|
|
if (this.twoOrThree == '三 维') {
|
this.$store.commit('SET_POINTPOSITION', [
|
Number(obj.lng),
|
Number(obj.lat),
|
Number(result.gd),
|
Number(result.heading),
|
Number(result.pitch),
|
Number(result.roll)
|
])
|
} else {
|
this.$store.commit('SET_POINTPOSITION', [
|
Number(result.jd),
|
Number(result.wd),
|
Number(result.gd),
|
Number(result.heading),
|
Number(result.pitch),
|
Number(result.roll)
|
])
|
}
|
},
|
newPopup (item, obj) {
|
if (this.twoOrThree == '三 维') {
|
this.$EventBus.$emit('openInfoWindowHtml', {
|
lng: Number(obj.lng),
|
lat: Number(obj.lat)
|
})
|
} else {
|
this.$EventBus.$emit('openInfoWindowHtml', {
|
lng: Number(item.jd),
|
lat: Number(item.wd)
|
})
|
}
|
|
this.$store.commit('SET_PANORAMAPOPUP', false)
|
this.$store.commit('SET_MONITORPOPUP', false)
|
this.$store.commit('SET_DETAILSPOPUP', true)
|
}
|
},
|
destroyed () {
|
if (ourLayer != null) {
|
this.map2D.removeLayer(ourLayer)
|
ourLayer = null
|
}
|
|
this.$store.commit('SET_DETAILSPOPUP', false)
|
this.$store.commit('SET_PANORAMAPOPUP', false)
|
this.$store.commit('SET_MONITORPOPUP', false)
|
}
|
}
|
</script>
|
|
<style scoped lang="scss"></style>
|