Browse Source

优化

shibei_master
ZhaoTongYao 3 years ago
parent
commit
c93bbb2a59
  1. 82
      src/views/modules/visual/components/screen-map/index.vue

82
src/views/modules/visual/components/screen-map/index.vue

@ -207,7 +207,6 @@ const vueGis = {
},
async mounted () {
},
methods: {
showPosition () {
@ -231,7 +230,6 @@ const vueGis = {
//
this.initMap()
if (this.showPolIconLayer) {
console.log('showPolIconLayer++++++++++++++++++++++', this.showPolIconLayer)
//
@ -246,6 +244,7 @@ const vueGis = {
this.loadPolygon()
}
if (this.showIconLayer) {
//icon
this.initIconLayer()
@ -296,7 +295,6 @@ const vueGis = {
}
this.setMapLocation()
// gaodeMapLayer.getSource().changed()
},
//
@ -355,6 +353,7 @@ const vueGis = {
this.loadPolIcon(feature)
}
}
},
@ -363,7 +362,7 @@ const vueGis = {
loadPolIcon (feature) {
polIconSource.clear()
let polyIconFeatures = [];
console.log('feature-----', feature)
// console.log('feature-----', feature)
feature.forEach(oneIcon => {
var extent = boundingExtent(oneIcon.getGeometry().getCoordinates()[0]); //[minx,miny,maxx,maxy]
@ -380,7 +379,7 @@ const vueGis = {
id: oneIcon.id_
}
});
// console.log('oneIcon----', oneIcon)
// console.log('oneIcon----ddd', oneIcon)
let polyIconStyle = new Style({
image: new Icon({
// anchor: [0.5, 0.5],
@ -416,12 +415,14 @@ const vueGis = {
info: { ...oneIcon }
}
});
// console.log('oneIcon----', this.iconUrlArray[oneIcon.urlIndex])
let iconStyle = new Style({
image: new Icon({
// anchor: [0.5, 0.5],
// imgSize: [32, 32],
// scale: 0.5,
src: oneIcon.urlIndex && this.iconUrlArray[oneIcon.urlIndex] || this.iconUrlArray[0]
// src: oneIcon.urlIndex && this.iconUrlArray[oneIcon.urlIndex] || this.iconUrlArray[0] || this.iconUrlArray[0]
src: (oneIcon.urlIndex && this.iconUrlArray[oneIcon.urlIndex]) || (oneIcon.index &&this.iconUrlArray[oneIcon.index]) || this.iconUrlArray[0]
}),
// text: createTextStyle(oneIcon)
});
@ -514,6 +515,46 @@ const vueGis = {
},
//
setMapLocation () {
if (!this.zoom) {
this.setZoom(this.mapInfo.agencyLevel)
}
this.centerPoint = []
//
if (this.center && this.center.length > 0) {
this.centerPoint = this.center
this.centerFlag = 'point'
this.center = []
} else if (polygonLayer.getSource().getFeatures()[0]) {//,
this.centerFlag = 'flag_polygon'
} else if (this.mapInfo.longitude && this.mapInfo.latitude) {
this.centerPoint.push(this.mapInfo.longitude)
this.centerPoint.push(this.mapInfo.latitude)
this.centerFlag = 'point'
} else {
this.centerPoint = centerPointGlobal
this.centerFlag = 'point'
}
// debugger
if (this.centerFlag === 'flag_parent') {
let parentFeatures = parentLayer.getSource().getFeatures()[0]
let polygon = parentFeatures.getGeometry();
map.getView().fit(polygon, map.getSize());
this.zoom = map.getView().getZoom() - 1
} else if (this.centerFlag === 'flag_polygon') {
let polygonFeatures = polygonLayer.getSource().getFeatures()[0]
let polygon = polygonFeatures.getGeometry();
map.getView().fit(polygon, map.getSize());
this.zoom = map.getView().getZoom() - 1
} else {
mapView.setCenter(this.centerPoint);
}
if (!this.isChangeCenter) {
return false
@ -579,13 +620,13 @@ const vueGis = {
},
//
setZoom (level) {
if (level === 'district') {
this.zoom = 11
} else if (level === 'street') {
this.zoom = 12
} else if (level === 'community') {
this.zoom = 13
setZoom(level) {
if (level === "district") {
this.zoom = 11;
} else if (level === "street") {
this.zoom = 12;
} else if (level === "community") {
this.zoom = 13;
}
},
@ -630,15 +671,18 @@ const vueGis = {
};
})();
// select = new Select({
// style: overlayStyle
// });
// BUG iconicon使icon ---zhaotongyao 2022.06.01
select = new Select({
style: overlayStyle
});
map.addLayer(polygonLayer)
// map.addInteraction(select);
map.addLayer(polygonLayer)
if (this.$route.path == '/main-shuju/visual-communityGovern-duoyuanfuwu-duoyuanfuwufenxi' || this.$route.path == '/main-shuju/visual-communityParty-gridParty' || this.$route.path == '/main-shuju/visual-communityParty-community') { // 2022.6.9
console.log('去掉默认点击')
} else {
map.addInteraction(select);
}
},
//icon

Loading…
Cancel
Save