智慧农业大数据平台
guanqb
2022-08-23 e005b8711f2b92bc11ad348a0a2f0a82cd148047
src/components/map/index.vue
@@ -4,7 +4,8 @@
</template>
<script>
import axios from 'axios'
// import axios from 'axios'
import NCregion from "@/assets/region"
// 图层变量做声明
var farmRegionLayer = null
@@ -212,19 +213,19 @@
        }
        global.DC.ready(initViewer)
        this.addRegionPolyLine('http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengfwx/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&returnTrueCurves=false&resultOffset=&resultRecordCount=&f=pjson')
        // this.addRegionPolyLine('http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengfwx/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&returnTrueCurves=false&resultOffset=&resultRecordCount=&f=pjson')
        this.addRegionPolyLine(NCregion)
    },
    methods: {
        /**
         * 添加南城县边界的数据
         * @param {string} url arcgis服务地址
         */
        addRegionPolyLine (url) {
            axios.get(url).then(res => {
        addRegionPolyLine (regionJSON) {
            // axios.get(regionJSON).then(res => {
                let position = ''
                res.data.features[0].geometry.rings[0].forEach(item => {
            regionJSON.features[0].geometry.rings[0].forEach(item => {
                    position += `${item[0]}, ${item[1]};`
                })
@@ -240,7 +241,7 @@
                    clampToGround: true
                })
                regionPolyLineLayer.addOverlay(polyline)
            })
            // })
        },
        /**
         * 添加农场点及范围的方法