From 40dc78a078b3777e9da768dbc20e749b9156c92d Mon Sep 17 00:00:00 2001
From: xiebin <123456>
Date: Sat, 03 Sep 2022 15:22:18 +0800
Subject: [PATCH] 基地根据经纬度定位显示icon
---
src/views/farm/index.vue | 26 ++++++------
src/views/home/index.vue | 22 +++++-----
src/components/map/index.vue | 35 +++++++++--------
3 files changed, 42 insertions(+), 41 deletions(-)
diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index e3ad160..a6261a7 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -258,10 +258,11 @@
* @param {*} positions 位置信息(范围信息)
* @param {*} item 基地对应的所有信息(接口返回的数据)
*/
- addPolygon (positions, item) {
+ addPolygon (item) {
const that = this
- const center = this.getCenter(positions)
+ // const center = this.getCenter(positions)
+ const center = [item.longitude, item.latitude]
const divIcon = new global.DC.DivIcon(
new global.DC.Position(center[0], center[1], 0),
@@ -453,27 +454,27 @@
* 设置中心点
* @param {*} name 对应站点(基地范围)的中心点 --- 对应的名字
*/
- setCenter (name) {
- let center
- addLayers.forEach(item => {
- if (name == item.name) {
- center = item.center
- }
- })
+ setCenter (farmObj) {
+ // let center
+ // addLayers.forEach(item => {
+ // if (name == item.name) {
+ // center = item.center
+ // }
+ // })
- if (center == '') {
- this.$message({
- message: '当前基地暂未绘制',
- type: 'warning'
- })
- return
- }
+ // if (center == '') {
+ // this.$message({
+ // message: '当前基地暂未绘制',
+ // type: 'warning'
+ // })
+ // return
+ // }
global.viewer.camera.flyTo({
// Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
// fromDegrees()方法,将经纬度和高程转换为世界坐标
destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
- center[0], center[1], 3000.0
+ farmObj.longitude, farmObj.latitude, 3000.0
),
orientation: {
// 指向
diff --git a/src/views/farm/index.vue b/src/views/farm/index.vue
index fdd2744..6402270 100644
--- a/src/views/farm/index.vue
+++ b/src/views/farm/index.vue
@@ -1126,21 +1126,21 @@
},
setView () {
- let position
+ // let position
+ //
+ // position = this.currentDetails.position.replace(/POLYGON\(\(/g, '')
+ // position = position.replace(/\)\)/g, '')
+ //
+ // const arr = position.split(',')
+ // var brr = []
+ //
+ // arr.forEach(it => {
+ // brr.push(it.split(' '))
+ // })
- position = this.currentDetails.position.replace(/POLYGON\(\(/g, '')
- position = position.replace(/\)\)/g, '')
+ this.$refs.modalForm.addPolygon(this.currentDetails)
- const arr = position.split(',')
- var brr = []
-
- arr.forEach(it => {
- brr.push(it.split(' '))
- })
-
- this.$refs.modalForm.addPolygon(brr, this.currentDetails)
-
- this.$refs.modalForm.setCenter(this.currentDetails.farmName)
+ this.$refs.modalForm.setCenter(this.currentDetails)
},
getSourceList (param) {
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 862ba58..10807c4 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -1388,8 +1388,8 @@
setCenter (item) {
this.ncListShow = false
// this.farmId = item.id
- this.AllDataUpdate()
- this.$refs.modalForm.setCenter(item.farmName)
+ // this.AllDataUpdate()
+ this.$refs.modalForm.setCenter(item)
},
setSiteCenter (item, show) {
@@ -1400,15 +1400,15 @@
getFarmList () {
getFarmList().then(res => {
res.data.data.forEach(item => {
- item.position = item.position.replace(/POLYGON\(\(/g, '')
- item.position = item.position.replace(/\)\)/g, '')
-
- const arr = item.position.split(',')
- var brr = []
- arr.forEach(it => {
- brr.push(it.split(' '))
- })
- this.$refs.modalForm.addPolygon(brr, item)
+ // item.position = item.position.replace(/POLYGON\(\(/g, '')
+ // item.position = item.position.replace(/\)\)/g, '')
+ //
+ // const arr = item.position.split(',')
+ // var brr = []
+ // arr.forEach(it => {
+ // brr.push(it.split(' '))
+ // })
+ this.$refs.modalForm.addPolygon(item)
})
this.farmNumArray = res.data.data
--
Gitblit v1.9.3