智慧农业大数据平台
xiebin
2022-09-03 40dc78a078b3777e9da768dbc20e749b9156c92d
基地根据经纬度定位显示icon
3 files modified
83 ■■■■ changed files
src/components/map/index.vue 35 ●●●● patch | view | raw | blame | history
src/views/farm/index.vue 26 ●●●● patch | view | raw | blame | history
src/views/home/index.vue 22 ●●●● patch | view | raw | blame | history
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: {
                    // 指向
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) {
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