智慧农业后台管理页面
guoshilong
2022-08-24 41dc8bedbfee679decb94d2df35c10fc003e258a
src/components/map/plotMap.vue
@@ -253,25 +253,22 @@
        addPlotPolygon (positions, item) {
            const that = this
            const center = this.getCenter(positions)
            // const divIcon = new global.DC.DivIcon(
            //     new global.DC.Position(center[0], center[1], 0),
            //     `
            //             <div class="farm-map-icon">
            //                 <img src="/img/icon/3858.png" alt="">
            //                 // <div>${item.farmName}</div>
            //             </div>
            //             `
            // )
            // divIcon.attrParams = item
            // farmLogoLayer.addOverlay(divIcon)
            // divIcon.on(global.DC.MouseEventType.CLICK, (e) => {
            //     that.$parent.showDetailPopup(e.overlay.attrParams)
            // })
            if(item.strainUrl !=""){
                const divIcon = new global.DC.DivIcon(
                    new global.DC.Position(center[0], center[1], 0),
                    `
                            <div class="farm-map-icon">
                                <img src="${item.strainUrl}" alt=""width="50%" height="50%" text-align="center">
                            </div>
                            `
                )
                divIcon.attrParams = item
                farmLogoLayer.addOverlay(divIcon)
                divIcon.on(global.DC.MouseEventType.CLICK, (e) => {
                    that.$parent.showDetailPopup(e.overlay.attrParams)
                })
            }
            const polygon = new global.DC.Polygon(positions)
            polygon.attrParams = item
            polygon.setStyle({
@@ -285,8 +282,10 @@
                that.$parent.plotDetailsPopupShow(e.overlay.attrParams)
            })
            console.log(item, 123)
            plotRegionLayer.addOverlay(polygon)
            addPlotLayers.push({ center, name: item.landName })
            addPlotLayers.push({ center, name: item.landName, id: item.id })
        },
        setCenter (name) {
@@ -337,6 +336,20 @@
            })
        },
        setPlotAttr (params) {
            let overLayers = plotRegionLayer.getOverlays()
            overLayers.some(item => {
                if (item.attrParams.id == params.id) {
                    item.attrParams = params
                    return true
                }
            })
        },
        // 经纬度测算中心位置
        getCenter (arr) {
            let centerLonLat = []