|
|
|
@ -194,12 +194,12 @@ export default {
|
|
|
|
|
CircleEditor.setTarget();
|
|
|
|
|
CircleEditor.open()
|
|
|
|
|
},
|
|
|
|
|
setPolygon(val) {
|
|
|
|
|
setPolygon(val, id) {
|
|
|
|
|
let e = val.map(r => {
|
|
|
|
|
let [lng, lat] = wgs84togcj02(r[0], r[1])
|
|
|
|
|
return [lng, lat]
|
|
|
|
|
})
|
|
|
|
|
let thisPolygon = new AMap.Polygon({path: e});
|
|
|
|
|
let thisPolygon = new AMap.Polygon({path: e, extData: {id: id}});
|
|
|
|
|
thisPolygon.on('dblclick', () => {
|
|
|
|
|
polyEditor.setTarget(thisPolygon);
|
|
|
|
|
polyEditor.open();
|
|
|
|
@ -211,11 +211,11 @@ export default {
|
|
|
|
|
map.add(thisPolygon)
|
|
|
|
|
map.setFitView()
|
|
|
|
|
},
|
|
|
|
|
setCircle(val) {
|
|
|
|
|
setCircle(val, id) {
|
|
|
|
|
let e = val
|
|
|
|
|
let [lng, lat] = wgs84togcj02(val.center[0], val.center[1])
|
|
|
|
|
e.center = [lng, lat]
|
|
|
|
|
let thisCircle = new AMap.Circle({center: e.center, radius: e.radius});
|
|
|
|
|
let thisCircle = new AMap.Circle({center: e.center, radius: e.radius, extData: {id: id}});
|
|
|
|
|
thisCircle.on('dblclick', () => {
|
|
|
|
|
CircleEditor.setTarget(thisCircle);
|
|
|
|
|
CircleEditor.open();
|
|
|
|
@ -230,31 +230,39 @@ export default {
|
|
|
|
|
getAreaData() {
|
|
|
|
|
let polygons = map.getAllOverlays('polygon');
|
|
|
|
|
let circles = map.getAllOverlays('circle');
|
|
|
|
|
let list = polygons.map(e => e._opts.path)//多边形
|
|
|
|
|
let list1 = circles.map(e => {//圆形
|
|
|
|
|
let list = polygons.map(e => {
|
|
|
|
|
return {
|
|
|
|
|
center: Array.isArray(e._opts.center) ? e._opts.center : [e._opts.center.lng, e._opts.center.lat],
|
|
|
|
|
radius: e._opts.radius
|
|
|
|
|
coordinates: e._opts.path,
|
|
|
|
|
id: e._opts?.extData?.id || null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let params = []
|
|
|
|
|
let params1 = []
|
|
|
|
|
list.forEach((e, index) => {
|
|
|
|
|
e.forEach(val => {
|
|
|
|
|
})//多边形
|
|
|
|
|
let params = list.map(e => {
|
|
|
|
|
let data = e.coordinates.map(val => {
|
|
|
|
|
let [lng, lat] = gcj02towgs84(val[0], val[1])
|
|
|
|
|
params.push({
|
|
|
|
|
return {
|
|
|
|
|
longitude: lng,
|
|
|
|
|
latitude: lat,
|
|
|
|
|
index: index
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return {
|
|
|
|
|
coordinates: data,
|
|
|
|
|
fenceAreaId: e.id || null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let list1 = circles.map(e => {//圆形
|
|
|
|
|
return {
|
|
|
|
|
center: Array.isArray(e._opts.center) ? e._opts.center : [e._opts.center.lng, e._opts.center.lat],
|
|
|
|
|
radius: e._opts.radius,
|
|
|
|
|
id: e._opts?.extData?.id || null
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let params1 = []
|
|
|
|
|
list1.forEach((e, index) => {
|
|
|
|
|
let [lng, lat] = gcj02towgs84(e.center[0], e.center[1])
|
|
|
|
|
params1.push({
|
|
|
|
|
center: [lng, lat],
|
|
|
|
|
radius: e.radius,
|
|
|
|
|
index: index
|
|
|
|
|
fenceAreaId: e.id || null
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -278,27 +286,18 @@ export default {
|
|
|
|
|
polygonAreaListArr.forEach(e1 => {
|
|
|
|
|
let polygonAreaListJson = JSON.parse(e1);
|
|
|
|
|
let polyJsonArr = JSON.parse(polygonAreaListJson["polyJsonArr"]);
|
|
|
|
|
let fenceAreaId = polygonAreaListJson["fenceAreaId"];
|
|
|
|
|
polyJsonArr.forEach(e => {
|
|
|
|
|
if (polygonData1[e.index]) {
|
|
|
|
|
polygonData1[e.index].push([e.longitude, e.latitude])
|
|
|
|
|
} else {
|
|
|
|
|
polygonData1[e.index] = [[e.longitude, e.latitude]]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
Object.keys(polygonData1).forEach(e => {
|
|
|
|
|
polygonData[e] = polygonData1[e]
|
|
|
|
|
})
|
|
|
|
|
polygonData.forEach(e => {
|
|
|
|
|
this.setPolygon(e)
|
|
|
|
|
let fenceAreaId = polygonAreaListJson["fenceAreaId"] || null;
|
|
|
|
|
console.log(polyJsonArr)
|
|
|
|
|
this.setPolygon(polyJsonArr.map(e => {
|
|
|
|
|
return [e.longitude, e.latitude]
|
|
|
|
|
}), fenceAreaId)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
circleAreaList.forEach(e => {
|
|
|
|
|
let fenceAreaId = e.fenceAreaId;
|
|
|
|
|
let fenceAreaId = e.fenceAreaId || null;
|
|
|
|
|
let center = JSON.parse(e.center);
|
|
|
|
|
let radius = e.radius;
|
|
|
|
|
this.setCircle({center, radius})
|
|
|
|
|
this.setCircle({center, radius}, fenceAreaId)
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|