Compare commits

...

2 Commits

View File

@ -24,8 +24,9 @@ const mapMixinLand = {
{ {
id: '03', id: '03',
landPath: 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, fillColor: '#ba8ae3', fillOpacity: 0.8, strokeColor: "#ba8ae3", strokeWeight: 1, strokeOpacity: 0.8,
}, },
@ -112,25 +113,16 @@ const mapMixinLand = {
if (areaList.length > 0) { if (areaList.length > 0) {
areaList.forEach((item) => { areaList.forEach((item) => {
if (item.landPath) { if (item.landPath) {
if (item.landPath && item.landPath.length && item.landPath.length > 0) {
item.landPath.forEach((k) => {
const path = []; const path = [];
const pointList = []; const pointList = [];
if( item.landPath && item.landPath.length && item.landPath.length>0){
item.landPath.forEach((k)=>{
k.split('|').forEach((point) => { k.split('|').forEach((point) => {
path.push(new this.AMap.LngLat(point.split(',')[0], point.split(',')[1])); path.push(new this.AMap.LngLat(point.split(',')[0], point.split(',')[1]));
pointList.push([Number(point.split(',')[0]), Number(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({ const polygon = new this.AMap.Polygon({
path: path, path: path,
fillColor: colorVal || item.fillColor, fillColor: colorVal || item.fillColor,
@ -142,6 +134,7 @@ const mapMixinLand = {
...item, ...item,
}, },
}); });
polygon.on('click', (e) => { polygon.on('click', (e) => {
this.createInfoWindow(e); this.createInfoWindow(e);
}); });
@ -150,24 +143,41 @@ const mapMixinLand = {
if (type == false) { if (type == false) {
overlayGroupNew.push(polygon) 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 (type) {
if (this.overlayGroup.length > 0) { if (this.overlayGroup.length > 0) {
this.map.add(new this.AMap.OverlayGroup(this.overlayGroup)); this.map.add(new this.AMap.OverlayGroup(this.overlayGroup));