修改地图数据

dev
夜笙歌 1 year ago
parent c710cb4e1b
commit 386a152367

@ -66,14 +66,9 @@ export default {
}, },
async mounted() { async mounted() {
await this.setSelectSecnes()
if (this.$store.state.user.permissions.includes('business:monitor:index') || this.$store.state.user.permissions.includes('*:*:*')) {
this.isIndex = true
} else {
this.isIndex = false
}
if (this.$route.name === 'SmartScene') { await this.setSelectSecnes()
if (this.$route.name === 'SmartScene'||this.$route.name === 'GPS' ) {
if (this.$route.query?.name) { if (this.$route.query?.name) {
this.name = this.$route.query?.name this.name = this.$route.query?.name
} else { } else {
@ -84,6 +79,11 @@ export default {
}); });
} }
} }
if (this.$store.state.user.permissions.includes('business:monitor:index') || this.$store.state.user.permissions.includes('*:*:*')) {
this.isIndex = true
} else {
this.isIndex = false
}
}, },
methods: { methods: {
async setSelectSecnes() { async setSelectSecnes() {

@ -174,25 +174,47 @@ export default {
center: [113.4, 23.35], center: [113.4, 23.35],
}); });
}, },
setText(e) {
let position = e.areaPoints?.length > 0 ? e.areaPoints:e.centerPoint
if(position.length>0){
let length = position.length
let longitudes = e.areaPoints.map(e=>e.longitude).reduce((a,b)=>a+b)
let latitudes = e.areaPoints.map(e=>e.latitude).reduce((a,b)=>a+b)
position = [longitudes/length, latitudes/length]
}else{
position = [e.centerPoint.longitude, e.centerPoint.latitude]
}
let text = new AMap.Text({
text: e.deviceCount + (e.abnormalCount ? ('/' + e.abnormalCount) : ''),
anchor: 'center',
draggable: true,
cursor: 'pointer',
position:position
});
map.add(text)
},
setPolygon(position) { setPolygon(position) {
let e = position.map(val => { let e = position.map(val => {
return [val.longitude, val.latitude] return [val.longitude, val.latitude]
}) })
let thisPolygon = new AMap.Polygon({path: e}); let thisPolygon = new AMap.Polygon({
path: e,
fillColor: e ? '#ff0000' : '#1791fc',
});
map.add(thisPolygon) map.add(thisPolygon)
map.setFitView() map.setFitView()
}, },
setCircle(center, radius) { setCircle(center, radius, e) {
let circle = new AMap.Circle({ let circle = new AMap.Circle({
center, center,
radius, radius,
borderWeight: 3, borderWeight: 3,
strokeColor: "#FF33FF", strokeColor: e ? '#ff0000' : "#FF33FF",
strokeWeight: 6, strokeWeight: 6,
strokeOpacity: 0.2, strokeOpacity: 0.2,
fillOpacity: 0.4, fillOpacity: 0.4,
strokeDasharray: [10, 10], strokeDasharray: [10, 10],
fillColor: '#1791fc', fillColor: e ? '#ff0000' : '#1791fc',
}) })
map.add(circle); map.add(circle);
map.setFitView() map.setFitView()
@ -269,8 +291,9 @@ export default {
this.setPolygon(e.areaPoints) this.setPolygon(e.areaPoints)
} }
if (e.centerPoint) { if (e.centerPoint) {
this.setCircle([e.centerPoint.longitude, e.centerPoint.latitude], e.radius) this.setCircle([e.centerPoint.longitude, e.centerPoint.latitude], e.radius, e.abnormalCount)
} }
this.setText(e)
}) })
} }
} }

@ -278,6 +278,7 @@ export default {
}) })
polygonData.forEach(e => { polygonData.forEach(e => {
this.setPolygon(e) this.setPolygon(e)
console.log(e)
}) })
circleAreaList.forEach(e => { circleAreaList.forEach(e => {

Loading…
Cancel
Save