修改电子围栏

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

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

Loading…
Cancel
Save