Browse Source

地图添加区域显示

shibei_master
13176889840 3 years ago
parent
commit
7e1098cae5
  1. 2
      src/views/modules/visual/communityParty/community.vue
  2. 63
      src/views/modules/visual/components/screen-map/index.vue

2
src/views/modules/visual/communityParty/community.vue

@ -91,6 +91,7 @@
:clickType="'popup'" :clickType="'popup'"
:showIconLayer="true" :showIconLayer="true"
:showPolIconLayer="true" :showPolIconLayer="true"
:areaScale="0.1"
@clickFeature="clickProject" @clickFeature="clickProject"
></screen-map> ></screen-map>
</div> </div>
@ -861,6 +862,7 @@ export default {
'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/a775d15e62374350b80e5cdf1912a4eb.png',
'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/884efcf6d6b44224a7fda599dd1b14cb.png' 'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20211116/884efcf6d6b44224a7fda599dd1b14cb.png'
] ]
this.$refs.map.loadMap(this.agencyInfo, this.parentPolygon, polIconUrlArray, this.unitMapList, this.iconUrlArray, null) this.$refs.map.loadMap(this.agencyInfo, this.parentPolygon, polIconUrlArray, this.unitMapList, this.iconUrlArray, null)
} else { } else {
this.$refs.map.refreshMap(null, this.unitMapList) this.$refs.map.refreshMap(null, this.unitMapList)

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

@ -79,6 +79,24 @@ let iconSource; // icon
let select;// let select;//
let iconTextsStyle = {
textAlign: undefined,
font: "18px Arial",
//fontFamily: "Courier New, monospace",
// fontWeight: "bold",
text: '',
backgroundFill: new Fill({
color: 'rgba(0, 146, 238, 0.75)'
// color: textColorArray[feature.values_.colorIndex]
}),
padding: [4, 10, 4, 10],
//text: "",
fill: new Fill({ color: "#ffffff" }),
// stroke: new Stroke({ color: "#ffffff", width: 3 }),
offsetY: -30,
offsetX: -50,
overflow: true,
}
let polygonColorArray = [ let polygonColorArray = [
'rgba(210, 2, 2, 0.24)', 'rgba(210, 2, 2, 0.24)',
@ -86,7 +104,19 @@ let polygonColorArray = [
'rgba(183, 185, 0, 0.16)' 'rgba(183, 185, 0, 0.16)'
]; ];
//icon
let createTextStyle = function (feature) {
if (iconTextsStyle) {
let iconTextsStyles = { ...iconTextsStyle }
iconTextsStyles.text = feature.values_ && feature.values_.name || feature.name
return new Text({ ...iconTextsStyles })
} else {
return null
}
}
// //
var polygonStyleFunction = (function () { var polygonStyleFunction = (function () {
return function (feature) { return function (feature) {
@ -105,6 +135,8 @@ var polygonStyleFunction = (function () {
}; };
})() })()
const vueGis = { const vueGis = {
name: 'HomeMap', name: 'HomeMap',
data () { data () {
@ -151,7 +183,7 @@ const vueGis = {
iconArrays: [ iconArrays: [
], ],
iconTextStyle: {}, // iconTextStyle: {},
//policon //policon
polIconUrlArray: [ polIconUrlArray: [
@ -183,7 +215,7 @@ const vueGis = {
this.polIconUrlArray = polIconUrlArray || [] this.polIconUrlArray = polIconUrlArray || []
this.iconArrays = iconArrays this.iconArrays = iconArrays
this.iconUrlArray = iconUrlArray this.iconUrlArray = iconUrlArray
this.iconTextStyle = iconTextStyle iconTextsStyle = iconTextStyle || iconTextsStyle
this.distanceMax = distanceMax this.distanceMax = distanceMax
// iconArrays.forEach(item => { // iconArrays.forEach(item => {
@ -313,7 +345,6 @@ const vueGis = {
//icon //icon
loadPolIcon (feature) { loadPolIcon (feature) {
console.log('feature----------', feature)
let polyIconFeatures = []; let polyIconFeatures = [];
feature.forEach(oneIcon => { feature.forEach(oneIcon => {
@ -336,16 +367,16 @@ const vueGis = {
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: this.areaScale,
src: this.polIconUrlArray[0] src: this.polIconUrlArray[0]
}) }),
text: createTextStyle(oneIcon)
}); });
polyIcon.setStyle(polyIconStyle); polyIcon.setStyle(polyIconStyle);
polyIconFeatures.push(polyIcon); polyIconFeatures.push(polyIcon);
}); });
console.log('polIconSource-----', polIconSource)
polIconSource.addFeatures(polyIconFeatures); polIconSource.addFeatures(polyIconFeatures);
}, },
@ -376,7 +407,7 @@ const vueGis = {
// scale: 0.5, // scale: 0.5,
src: this.iconUrlArray[oneIcon.urlIndex] src: this.iconUrlArray[oneIcon.urlIndex]
}), }),
text: this.createTextStyle(oneIcon) // text: createTextStyle(oneIcon)
}); });
iconItem.setStyle(iconStyle); iconItem.setStyle(iconStyle);
@ -398,18 +429,6 @@ const vueGis = {
} }
}, },
//icon
createTextStyle (feature) {
if (this.iconTextStyle) {
let iconTextStyle = { ...this.iconTextStyle }
iconTextStyle.text = feature.values_.name
return new Text({ ...iconTextStyle })
} else {
return null
}
},
// //
computedDistance (lon, lat, max) { computedDistance (lon, lat, max) {
@ -536,7 +555,7 @@ const vueGis = {
}) })
}), }),
new Style({ new Style({
text: that.createTextStyle(feature) text: createTextStyle(feature)
}) })
]; ];
styles['MultiPolygon'] = styles['Polygon']; styles['MultiPolygon'] = styles['Polygon'];
@ -712,6 +731,10 @@ const vueGis = {
clickType: { clickType: {
type: String, type: String,
default: 'back' default: 'back'
},
areaScale: {
type: Number,
default: 0.5
} }
}, },

Loading…
Cancel
Save