This commit is contained in:
李想 2025-04-21 16:08:52 +08:00
commit 3338c77760

View File

@ -24,8 +24,9 @@ const mapMixinLand = {
{
id: '03',
landPath:
["99.853174,24.424073|99.850256,24.426105|99.855749,24.426731|99.880812,24.421885",
[
"99.853174,24.424073|99.850256,24.426105|99.855749,24.426731|99.880812,24.421885",
"99.8587581,24.4150345|99.8603841,24.4127477|99.8581922,24.4129616"
],
fillColor: '#ba8ae3', fillOpacity: 0.8, strokeColor: "#ba8ae3", strokeWeight: 1, strokeOpacity: 0.8,
},
@ -112,25 +113,16 @@ const mapMixinLand = {
if (areaList.length > 0) {
areaList.forEach((item) => {
if (item.landPath) {
if (item.landPath && item.landPath.length && item.landPath.length > 0) {
item.landPath.forEach((k) => {
const path = [];
const pointList = [];
if( item.landPath && item.landPath.length && item.landPath.length>0){
item.landPath.forEach((k)=>{
k.split('|').forEach((point) => {
path.push(new this.AMap.LngLat(point.split(',')[0], point.split(',')[1]));
pointList.push([Number(point.split(',')[0]), Number(point.split(',')[1])]);
});
})
}
let colorVal='';
if(options && options.length>0){
let indexF=options.findIndex((m)=>{
return m.id==item.id
})
colorVal=indexF>-1 ? options[indexF].color : ''
}
const polygon = new this.AMap.Polygon({
path: path,
fillColor: colorVal || item.fillColor,
@ -142,6 +134,7 @@ const mapMixinLand = {
...item,
},
});
polygon.on('click', (e) => {
this.createInfoWindow(e);
});
@ -150,24 +143,41 @@ const mapMixinLand = {
if (type == false) {
overlayGroupNew.push(polygon)
}
// 添加地块名称
label.push(
new this.AMap.Text({
text: item.landName ? item.landName : '名称',
anchor: 'center',
position: this.getAreaCenter(pointList),
style: {
background: 'transparent',
color: '#fff',
border: 'none',
fontSize: '16px',
},
})
);
}
let colorVal = '';
if (options && options.length > 0) {
let indexF = options.findIndex((m) => {
return m.id == item.id
})
colorVal = indexF > -1 ? options[indexF].color : ''
}
// const polygon = new this.AMap.Polygon({
// path: path,
// fillColor:colorVal|| item.fillColor,
// fillOpacity: item.fillOpacity,
// strokeColor:colorVal || '',
// strokeWeight: colorVal|| item.fillColor,
// strokeOpacity: item.strokeOpacity,
// extData: {
// ...item,
// },
// });
// polygon.on('click', (e) => {
// this.createInfoWindow(e);
// });
// this.overlayGroup.push(polygon);
// if(type==false){
// overlayGroupNew.push(polygon)
// }
}
});
}
// this.map.add(new this.AMap.OverlayGroup(label));
if (type) {
if (this.overlayGroup.length > 0) {
this.map.add(new this.AMap.OverlayGroup(this.overlayGroup));