From c518ffa02013402da032a18941f96ec2dcab9c8b Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 26 Oct 2022 09:08:17 +0800
Subject: [PATCH] 用户管理返回封禁状态
---
src/components/map/plotMap.vue | 67 +++++++++++++++++++--------------
1 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/src/components/map/plotMap.vue b/src/components/map/plotMap.vue
index ede9dc4..f4ba809 100644
--- a/src/components/map/plotMap.vue
+++ b/src/components/map/plotMap.vue
@@ -234,7 +234,12 @@
getDetail(this.$farmId).then(res=>{
this.farm.latitude = res.data.data.latitude
this.farm.longitude = res.data.data.longitude
- global.DC.ready(initViewer(this.farm.latitude,this.farm.longitude))
+ // global.DC.ready(initViewer(this.farm.latitude,this.farm.longitude))
+
+ global.DC.ready(() => {
+ initViewer(this.farm.latitude,this.farm.longitude)
+ })
+
this.addRegionPolyLine(NCregion)
})
},
@@ -341,23 +346,25 @@
// })
// farmLogoLayer.addOverlay(divIcon)
}
- const polygon = new global.DC.Polygon(positions)
- polygon.attrParams = item
- polygon.setStyle({
- material: global.DC.Namespace.Cesium.Color.fromBytes(
- 129, 255, 84,
- 200
- )
- })
+ if(positions){
+ const polygon = new global.DC.Polygon(positions)
+ polygon.attrParams = item
+ polygon.setStyle({
+ material: global.DC.Namespace.Cesium.Color.fromBytes(
+ 129, 255, 84,
+ 200
+ )
+ })
- polygon.on(global.DC.MouseEventType.CLICK, (e) => {
- that.$parent.plotDetailsPopupShow(e.overlay.attrParams)
- that.drawLandPolyLine(positions)
- })
+ polygon.on(global.DC.MouseEventType.CLICK, (e) => {
+ that.$parent.plotDetailsPopupShow(e.overlay.attrParams)
+ that.drawLandPolyLine(positions)
+ })
- plotRegionLayer.addOverlay(polygon)
- addPlotLayers.push({ center, name: item.landName, id: item.id })
+ plotRegionLayer.addOverlay(polygon)
+ addPlotLayers.push({ center, name: item.landName, id: item.id })
+ }
},
/**
* 地块画线
@@ -474,18 +481,7 @@
// 经纬度测算中心位置
getCenter (arr) {
- var positionArr = []
- arr.forEach(e=>{
- // e = new global.DC.Namespace.Cesium.Cartesian3(e[0]-0, e[1]-0, 0)
- e[0] = e[0]-0
- e[1] = e[1]-0
- positionArr.push(e)
- })
- positionArr.push(arr[0])
- var positionTurf = [positionArr]
- var polygon = turf.polygon(positionTurf);
- var centroid = turf.centroid(polygon);
- let centerLonLat = []
+
// if (arr.length) {
// const lon = []
// const lat = []
@@ -509,7 +505,22 @@
// centerLonLat = [Number(centerLongitude), Number(centerLatitude)]
// console.log("中心",centerLonLat)
// }
- centerLonLat = [centroid.geometry.coordinates[0],centroid.geometry.coordinates[1]]
+ let centerLonLat = []
+ if(arr.length >= 3 ){
+ var positionArr = []
+ arr.forEach(e=>{
+ // e = new global.DC.Namespace.Cesium.Cartesian3(e[0]-0, e[1]-0, 0)
+ e[0] = e[0]-0
+ e[1] = e[1]-0
+ positionArr.push(e)
+ })
+ positionArr.push(arr[0])
+ var positionTurf = [positionArr]
+ var polygon = turf.polygon(positionTurf);
+ var centroid = turf.centroid(polygon);
+
+ centerLonLat = [centroid.geometry.coordinates[0],centroid.geometry.coordinates[1]]
+ }
return centerLonLat
}
}
--
Gitblit v1.9.3