修改电子围栏

dev
夜笙歌 1 year ago
parent e12fe302a7
commit 9d92c8c968

@ -54,7 +54,6 @@ import {
delElectronicFence, delElectronicFence,
addElectronicFence, addElectronicFence,
updateElectronicFence, updateElectronicFence,
getEditedScenes
} from "@/api/business/electronicFence"; } from "@/api/business/electronicFence";
let map = null let map = null
@ -103,25 +102,29 @@ export default {
} }
}, },
created() { created() {
getEditedScenes().then(response => {
this.editedScenes = response.data;
});
}, },
mounted() { async mounted() {
await this.isAMap()
this.getEditedElectronicFence(); this.getEditedElectronicFence();
map = new AMap.Map('map', { map = new AMap.Map('map', {
zoom: 11, zoom: 11,
center: [113.4, 23.35], center: [113.4, 23.35],
}); });
await this.isMapLoading()
CircleEditor = new AMap.CircleEditor(map); CircleEditor = new AMap.CircleEditor(map);
CircleEditor.on('add', function (data) { CircleEditor.on('add', function (data) {
let circle = data.target; let circle = data.target;
// CircleEditor.addAdsorbCircles(circle); // CircleEditor.addAdsorbCircles(circle);
circle.on('dblclick', () => { circle.on('dblclick', () => {
CircleEditor.setTarget(circle); CircleEditor.setTarget(circle);
polyEditor.close();
CircleEditor.open(); CircleEditor.open();
}) })
circle.on('rightclick', () => {
CircleEditor.close();
map.remove(circle);
})
}) })
polyEditor = new AMap.PolygonEditor(map); polyEditor = new AMap.PolygonEditor(map);
polyEditor.on('add', function (data) { polyEditor.on('add', function (data) {
@ -129,11 +132,42 @@ export default {
polyEditor.addAdsorbPolygons(polygon); polyEditor.addAdsorbPolygons(polygon);
polygon.on('dblclick', () => { polygon.on('dblclick', () => {
polyEditor.setTarget(polygon); polyEditor.setTarget(polygon);
CircleEditor.close();
polyEditor.open(); polyEditor.open();
}) })
polygon.on('rightclick', () => {
CircleEditor.close();
polyEditor.close();
map.remove(polygon);
})
}) })
}, },
methods: { methods: {
isAMap(){
return new Promise((a,b)=>{
let fun = ()=>{
if(typeof AMap ==='object'){
a()
}else{
setTimeout(fun,100)
}
}
fun()
})
},
isMapLoading(){
return new Promise((a,b)=>{
let fun = ()=>{
if(map){
a()
}else{
setTimeout(fun,100)
}
}
fun()
})
},
clear() { clear() {
if (!polyEditor) return if (!polyEditor) return
CircleEditor.close(); CircleEditor.close();
@ -144,11 +178,13 @@ export default {
map.remove(circles) map.remove(circles)
}, },
createPolygon() { createPolygon() {
CircleEditor.close();
polyEditor.close(); polyEditor.close();
polyEditor.setTarget(); polyEditor.setTarget();
polyEditor.open() polyEditor.open()
}, },
createCircle() { createCircle() {
polyEditor.close();
CircleEditor.close(); CircleEditor.close();
CircleEditor.setTarget(); CircleEditor.setTarget();
CircleEditor.open() CircleEditor.open()
@ -159,6 +195,10 @@ export default {
polyEditor.setTarget(thisPolygon); polyEditor.setTarget(thisPolygon);
polyEditor.open(); polyEditor.open();
}) })
thisPolygon.on('rightclick', () => {
polyEditor.close();
map.remove(thisPolygon);
})
map.add(thisPolygon) map.add(thisPolygon)
map.setFitView() map.setFitView()
}, },
@ -168,6 +208,10 @@ export default {
CircleEditor.setTarget(thisCircle); CircleEditor.setTarget(thisCircle);
CircleEditor.open(); CircleEditor.open();
}) })
thisCircle.on('rightclick', () => {
CircleEditor.close();
map.remove(thisCircle);
})
map.add(thisCircle) map.add(thisCircle)
map.setFitView() map.setFitView()
}, },

Loading…
Cancel
Save