|
|
@ -29,8 +29,15 @@ |
|
|
|
@refreshInfoList="refreshInfoList"></basic-info-community> |
|
|
|
|
|
|
|
<div v-show="orgLevel!=='people' && orgLevel!=='search' && orgLevel!=='neighborHood'" |
|
|
|
class="div_map" |
|
|
|
id="map" |
|
|
|
class="div_map"> |
|
|
|
ref="map"> |
|
|
|
<!-- <div id="map" |
|
|
|
class="map"></div> --> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="popup" |
|
|
|
ref="popup"> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="div_data"> |
|
|
@ -98,8 +105,15 @@ import XYZ from 'ol/source/XYZ.js'; |
|
|
|
import VectorLayer from 'ol/layer/Vector.js'; |
|
|
|
import VectorSource from 'ol/source/Vector.js'; |
|
|
|
import GeoJSON from 'ol/format/GeoJSON.js'; |
|
|
|
import Point from "ol/geom/Point.js"; |
|
|
|
import Feature from "ol/Feature.js"; |
|
|
|
import Overlay from 'ol/Overlay'; |
|
|
|
import { defaults as defaultInteractions, Select, DoubleClickZoom } from 'ol/interaction.js'; |
|
|
|
import { Circle as CircleStyle, Fill, Stroke, Style, Text } from 'ol/style.js'; |
|
|
|
import { getCenter, boundingExtent } from 'ol/extent.js'; |
|
|
|
import { Circle as CircleStyle, Icon, Fill, Stroke, Style, Text } from 'ol/style.js'; |
|
|
|
import { toStringHDMS } from 'ol/coordinate' |
|
|
|
|
|
|
|
import { fromLonLat, toLonLat } from "ol/proj"; |
|
|
|
import { mapGetters } from "vuex"; |
|
|
|
import { Loading } from 'element-ui'; //引入Loading服务 |
|
|
|
import { requestPost } from "@/js/dai/request"; |
|
|
@ -117,34 +131,62 @@ let map; |
|
|
|
let mapView; |
|
|
|
let gaodeMapLayer;//背景地图图层 |
|
|
|
let polygonLayer;//变电站标注图层 |
|
|
|
let iconLayer; // icon标注图层 |
|
|
|
let iconSource; // icon |
|
|
|
let polygonSource;//变电站标注多边形 |
|
|
|
let select;//选中标注 |
|
|
|
|
|
|
|
|
|
|
|
//url图标 |
|
|
|
|
|
|
|
let iconUrlArray = [ |
|
|
|
'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/a219130b6bc74b0b80b5ddb0fce0892a.png', |
|
|
|
'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/a775d15e62374350b80e5cdf1912a4eb.png', |
|
|
|
'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/884efcf6d6b44224a7fda599dd1b14cb.png' |
|
|
|
]; |
|
|
|
let textColorArray = [ |
|
|
|
'rgba(236, 69, 4, 0.66)', |
|
|
|
'rgba(0, 146, 238, 0.75)', |
|
|
|
'rgba(238, 151, 0, 0.8)' |
|
|
|
]; |
|
|
|
let polygonColorArray = [ |
|
|
|
'rgba(210, 2, 2, 0.24)', |
|
|
|
'rgba(43, 231, 253, 0.25)', |
|
|
|
'rgba(183, 185, 0, 0.16)' |
|
|
|
]; |
|
|
|
//变电站标注的文字样式 |
|
|
|
var createTextStyle = function (feature) { |
|
|
|
return new Text({ |
|
|
|
textAlign: undefined, |
|
|
|
font: "bold 18px Arial", |
|
|
|
font: "18px Arial", |
|
|
|
//fontFamily: "Courier New, monospace", |
|
|
|
fontWeight: "bold", |
|
|
|
// fontWeight: "bold", |
|
|
|
text: feature.values_.name, |
|
|
|
backgroundFill: new Fill({ |
|
|
|
// color: 'rgba(0, 146, 238, 0.75)' |
|
|
|
color: textColorArray[feature.values_.index - 1] |
|
|
|
}), |
|
|
|
padding: [4, 10, 4, 10], |
|
|
|
//text: "变电站名称", |
|
|
|
fill: new Fill({ color: "#007ab9" }), |
|
|
|
stroke: new Stroke({ color: "#ffffff", width: 3 }), |
|
|
|
offsetY: 0, |
|
|
|
fill: new Fill({ color: "#ffffff" }), |
|
|
|
// stroke: new Stroke({ color: "#ffffff", width: 3 }), |
|
|
|
offsetY: -30, |
|
|
|
offsetX: -50, |
|
|
|
overflow: true, |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
//变电站标注样式 |
|
|
|
|
|
|
|
var polygonStyleFunction = (function () { |
|
|
|
return function (feature) { |
|
|
|
return new Style({ |
|
|
|
fill: new Fill({ |
|
|
|
color: [255, 255, 255, 0.3] |
|
|
|
// color: [255, 255, 255, 0.3] |
|
|
|
color: polygonColorArray[feature.values_.index - 1] |
|
|
|
}), |
|
|
|
stroke: new Stroke({ |
|
|
|
color: [0, 153, 255, 1], |
|
|
|
color: polygonColorArray[feature.values_.index - 1], |
|
|
|
width: 3 |
|
|
|
}), |
|
|
|
|
|
|
@ -166,6 +208,9 @@ const vueGis = { |
|
|
|
orgLevel: '', |
|
|
|
|
|
|
|
subAgencyArray: [],//下拉框数据 |
|
|
|
iconCoordinators: [], |
|
|
|
currentCoordinate: null, |
|
|
|
overlay: null, |
|
|
|
|
|
|
|
//右侧搜索 |
|
|
|
searchName: "", |
|
|
@ -173,92 +218,6 @@ const vueGis = { |
|
|
|
//右侧列表 |
|
|
|
listData: [],//得到的数据 |
|
|
|
listDatashow: [],//处理成一行两列的数据 |
|
|
|
listData1: [ |
|
|
|
{ |
|
|
|
id: "1", |
|
|
|
label: "党员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dabing.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "2", |
|
|
|
label: "低保人员", |
|
|
|
count: 30000, |
|
|
|
dataIcon: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "3", |
|
|
|
label: "保障房人员", |
|
|
|
count: 3, |
|
|
|
dataIcon: '' |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "4", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "5", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "6", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "7", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "8", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "9", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "10", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "11", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "12", |
|
|
|
label: "失业人员", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "13", |
|
|
|
label: "失业人员3", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: "14", |
|
|
|
label: "失业人员2", |
|
|
|
count: 300, |
|
|
|
dataIcon: require('../../../../assets/img/modules/visual/dibao.png') |
|
|
|
}, |
|
|
|
], |
|
|
|
|
|
|
|
//下钻层级记录 |
|
|
|
runNum: 0, |
|
|
@ -278,6 +237,9 @@ const vueGis = { |
|
|
|
//添加标注图层 |
|
|
|
this.addPolygonLayer() |
|
|
|
|
|
|
|
//添加icontuceng |
|
|
|
this.addIconLayer() |
|
|
|
|
|
|
|
//加载当前园区的标注 |
|
|
|
this.loadPolygon(this.subAgencyArray) |
|
|
|
|
|
|
@ -484,13 +446,16 @@ const vueGis = { |
|
|
|
subAgencyArray.forEach(agencyItem => { |
|
|
|
|
|
|
|
if (agencyItem.coordinates && agencyItem.coordinates !== '') {//如果有坐标 |
|
|
|
let urlNum = this.getRndBetween(1, 3) |
|
|
|
|
|
|
|
oneData = { |
|
|
|
type: 'Feature', |
|
|
|
id: agencyItem.id, |
|
|
|
properties: { |
|
|
|
id: agencyItem.id, |
|
|
|
level: agencyItem.level, |
|
|
|
name: agencyItem.name |
|
|
|
name: agencyItem.name, |
|
|
|
index: urlNum//颜色随机的索引 |
|
|
|
}, |
|
|
|
geometry: { |
|
|
|
type: 'Polygon', |
|
|
@ -526,12 +491,56 @@ const vueGis = { |
|
|
|
'features': featureData |
|
|
|
}; |
|
|
|
let feature = (new GeoJSON()).readFeatures(geojsonObject) |
|
|
|
|
|
|
|
polygonSource.addFeatures(feature) |
|
|
|
|
|
|
|
let iconFeatures = []; |
|
|
|
feature.forEach(oneIcon => { |
|
|
|
var extent = boundingExtent(oneIcon.getGeometry().getCoordinates()[0]); //获取一个坐标数组的边界,格式为[minx,miny,maxx,maxy] |
|
|
|
// var center = getCenter(extent); //获取边界区域的中心位置 |
|
|
|
//添加标注 |
|
|
|
let x = (parseFloat(extent[0]) + parseFloat(extent[2])) / 2 |
|
|
|
let y = (parseFloat(extent[1]) + parseFloat(extent[3])) / 2 |
|
|
|
|
|
|
|
let oneArray = [x, y] |
|
|
|
this.iconCoordinators.push(oneArray) |
|
|
|
|
|
|
|
//视频监控样式 |
|
|
|
let oneCctv = new Feature({ |
|
|
|
geometry: new Point([x, y]), |
|
|
|
id: oneIcon.id, |
|
|
|
properties: { |
|
|
|
type: "icon", |
|
|
|
id: oneIcon.id |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
console.log(oneIcon.values_) |
|
|
|
|
|
|
|
let iconStyle = new Style({ |
|
|
|
image: new Icon({ |
|
|
|
// anchor: [0.5, 0.5], |
|
|
|
// imgSize: [32, 32], |
|
|
|
scale: 0.5, |
|
|
|
// src: "/img/largeScreen/icon_camra.png" |
|
|
|
// src: "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/a219130b6bc74b0b80b5ddb0fce0892a.png" |
|
|
|
src: iconUrlArray[oneIcon.values_.index - 1] |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
|
oneCctv.setStyle(iconStyle); |
|
|
|
iconFeatures.push(oneCctv); |
|
|
|
|
|
|
|
}); |
|
|
|
console.log(iconFeatures) |
|
|
|
|
|
|
|
iconSource.clear(); //清空cctyv标注 |
|
|
|
iconSource.addFeatures(iconFeatures); |
|
|
|
} |
|
|
|
|
|
|
|
// this.addGif() |
|
|
|
|
|
|
|
}, |
|
|
|
//设置地图定位的中心点和缩放级别 |
|
|
|
setMapLocation () { |
|
|
|
this.centerPoint = [] |
|
|
@ -576,19 +585,41 @@ const vueGis = { |
|
|
|
projection: 'EPSG:4326', |
|
|
|
zoom: this.zoom, |
|
|
|
minZoom: this.minZoom |
|
|
|
}), |
|
|
|
}) |
|
|
|
// 弹窗 |
|
|
|
this.overlay = new Overlay({ |
|
|
|
element: this.$refs.popup, // 弹窗标签,在html里 |
|
|
|
autoPan: true, // 如果弹窗在底图边缘时,底图会移动 |
|
|
|
autoPanAnimation: { // 底图移动动画 |
|
|
|
duration: 250 |
|
|
|
} |
|
|
|
}) |
|
|
|
console.log(this.overlay) |
|
|
|
//初始化map和地图底图 |
|
|
|
//创建地图容器 |
|
|
|
map = new Map({ |
|
|
|
layers: [gaodeMapLayer], |
|
|
|
//加载瓦片图层数据 |
|
|
|
view: mapView, |
|
|
|
target: 'map' |
|
|
|
target: 'map', |
|
|
|
overlays: [this.overlay], // 把弹窗加入地图 |
|
|
|
//目标加载到map中 |
|
|
|
}) |
|
|
|
|
|
|
|
let that = this |
|
|
|
map.on('singleclick', function (e) { |
|
|
|
console.log(e.coordinate) |
|
|
|
const coordinate = e.coordinate // 获取坐标 |
|
|
|
const hdms = toStringHDMS(toLonLat(coordinate)) // 转换坐标格式 |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
// 设置弹窗位置 |
|
|
|
// 这里要设置定时器,不然弹窗首次出现,底图会跑偏 |
|
|
|
that.currentCoordinate = hdms // 保存坐标点 |
|
|
|
that.overlay.setPosition(coordinate) |
|
|
|
|
|
|
|
}, 0) |
|
|
|
// console.log(transform(e.coordinate, 'EPSG:3857', 'EPSG:4326')); |
|
|
|
|
|
|
|
}) |
|
|
@ -657,6 +688,25 @@ const vueGis = { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
addIconLayer () { |
|
|
|
iconSource = new VectorSource({ |
|
|
|
//features: (new GeoJSON()).readFeatures(geojsonObject) |
|
|
|
}); |
|
|
|
|
|
|
|
iconLayer = new VectorLayer({ |
|
|
|
source: iconSource, |
|
|
|
zIndex: 70 |
|
|
|
}); |
|
|
|
|
|
|
|
map.addLayer(iconLayer); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//取随机数 |
|
|
|
getRndBetween (lowerLimit, upperLimit) { |
|
|
|
return Math.floor(Math.random() * (upperLimit - lowerLimit + 1)) + lowerLimit; |
|
|
|
}, |
|
|
|
|
|
|
|
//开启加载动画 |
|
|
|
startLoading () { |
|
|
|
loading = Loading.service({ |
|
|
@ -715,7 +765,12 @@ export default vueGis; |
|
|
|
scoped |
|
|
|
></style> |
|
|
|
|
|
|
|
<style lang=scss> |
|
|
|
<style lang="scss" > |
|
|
|
.div_content { |
|
|
|
.ol-viewport { |
|
|
|
border-radius: 5px; |
|
|
|
} |
|
|
|
} |
|
|
|
.ol-overlaycontainer-stopevent { |
|
|
|
display: none; |
|
|
|
} |
|
|
|