Browse Source

优化

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

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

@ -197,7 +197,7 @@ const vueGis = {
//icon //icon
iconUrlArray: [], iconUrlArray: [],
iconTextColor: '#ffffff', iconTextColor: '#ffffff',
distanceMax: null,// distanceMax: null,//
input_lat: null, input_lat: null,
input_lon: null, input_lon: null,
@ -207,7 +207,6 @@ const vueGis = {
}, },
async mounted () { async mounted () {
}, },
methods: { methods: {
showPosition () { showPosition () {
@ -231,7 +230,6 @@ const vueGis = {
// //
this.initMap() this.initMap()
if (this.showPolIconLayer) { if (this.showPolIconLayer) {
console.log('showPolIconLayer++++++++++++++++++++++', this.showPolIconLayer) console.log('showPolIconLayer++++++++++++++++++++++', this.showPolIconLayer)
// //
@ -246,6 +244,7 @@ const vueGis = {
this.loadPolygon() this.loadPolygon()
} }
if (this.showIconLayer) { if (this.showIconLayer) {
//icon //icon
this.initIconLayer() this.initIconLayer()
@ -296,7 +295,6 @@ const vueGis = {
} }
this.setMapLocation() this.setMapLocation()
// gaodeMapLayer.getSource().changed() // gaodeMapLayer.getSource().changed()
}, },
// //
@ -355,6 +353,7 @@ const vueGis = {
this.loadPolIcon(feature) this.loadPolIcon(feature)
} }
} }
}, },
@ -363,7 +362,7 @@ const vueGis = {
loadPolIcon (feature) { loadPolIcon (feature) {
polIconSource.clear() polIconSource.clear()
let polyIconFeatures = []; let polyIconFeatures = [];
console.log('feature-----', feature) // console.log('feature-----', feature)
feature.forEach(oneIcon => { feature.forEach(oneIcon => {
var extent = boundingExtent(oneIcon.getGeometry().getCoordinates()[0]); //[minx,miny,maxx,maxy] var extent = boundingExtent(oneIcon.getGeometry().getCoordinates()[0]); //[minx,miny,maxx,maxy]
@ -380,7 +379,7 @@ const vueGis = {
id: oneIcon.id_ id: oneIcon.id_
} }
}); });
// console.log('oneIcon----', oneIcon) // console.log('oneIcon----ddd', oneIcon)
let polyIconStyle = new Style({ let polyIconStyle = new Style({
image: new Icon({ image: new Icon({
// anchor: [0.5, 0.5], // anchor: [0.5, 0.5],
@ -416,12 +415,14 @@ const vueGis = {
info: { ...oneIcon } info: { ...oneIcon }
} }
}); });
// console.log('oneIcon----', this.iconUrlArray[oneIcon.urlIndex])
let iconStyle = new Style({ let iconStyle = new Style({
image: new Icon({ image: new Icon({
// anchor: [0.5, 0.5], // anchor: [0.5, 0.5],
// imgSize: [32, 32], // imgSize: [32, 32],
// scale: 0.5, // 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) // text: createTextStyle(oneIcon)
}); });
@ -454,8 +455,8 @@ const vueGis = {
return (distance < max || distance === max) return (distance < max || distance === max)
// debugger // debugger
// return // return
// var wgs84Sphere = new ol.Sphere(6378137); // var wgs84Sphere = new ol.Sphere(6378137);
// wgs84Sphere.haversineDistance([120.21592590991689, 30.210793016606],[120.21670777384473, 30.211168525868086]); // wgs84Sphere.haversineDistance([120.21592590991689, 30.210793016606],[120.21670777384473, 30.211168525868086]);
}, },
@ -514,6 +515,46 @@ const vueGis = {
}, },
// //
setMapLocation () { 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) { if (!this.isChangeCenter) {
return false return false
@ -579,13 +620,13 @@ const vueGis = {
}, },
// //
setZoom (level) { setZoom(level) {
if (level === 'district') { if (level === "district") {
this.zoom = 11 this.zoom = 11;
} else if (level === 'street') { } else if (level === "street") {
this.zoom = 12 this.zoom = 12;
} else if (level === 'community') { } else if (level === "community") {
this.zoom = 13 this.zoom = 13;
} }
}, },
@ -630,15 +671,18 @@ const vueGis = {
}; };
})(); })();
// select = new Select({ select = new Select({
// style: overlayStyle style: overlayStyle
// }); });
// BUG iconicon使icon ---zhaotongyao 2022.06.01
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 //icon
@ -917,4 +961,4 @@ export default vueGis;
// color: rgba(1, 17, 104, 1); // color: rgba(1, 17, 104, 1);
color: #fff; color: #fff;
} }
</style> </style>
Loading…
Cancel
Save