修改地图

dev
夜笙歌 1 year ago
parent 24975487c6
commit 15a5c13d70

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

@ -35,9 +35,10 @@ module.exports = {
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
target: `http://127.0.0.1:9080`, // target: `http://127.0.0.1:9080`,
// target: `http://10.11.40.120:9080`, target: `http://10.11.40.120:9080`,
// target: `http://10.11.43.111:8080`, // target: `http://10.11.43.111:8080`,
// target: `http://175.27.215.92:9080`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''

Loading…
Cancel
Save