智慧农业大数据平台
shuishen
2022-08-15 b7fac22aee53d4eb656ec30ad53db9feef5494b3
map注释添加
1 files modified
44 ■■■■■ changed files
src/components/map/index.vue 44 ●●●●● patch | view | raw | blame | history
src/components/map/index.vue
@@ -5,6 +5,7 @@
<script>
// 图层变量做声明
var farmRegionLayer = null
var plotRegionLayer = null
var farmLogoLayer = null
@@ -31,7 +32,9 @@
            global.viewer = null
        }
        // 初始化地图
        function initViewer () {
            // new Viewer(new 地图)
            global.viewer = new global.DC.Viewer('viewer-container', {
                contextOptions: {
                    webgl: {
@@ -44,6 +47,7 @@
            // global.viewer.scene.globe.depthTestAgainstTerrain = true
            // 已声明的图层添加到地图上
            farmRegionLayer = new global.DC.VectorLayer('farmRegionLayer')
            global.viewer.addLayer(farmRegionLayer)
@@ -56,13 +60,14 @@
            siteEntitylayers = new global.DC.VectorLayer('siteEntitylayers')
            global.viewer.addLayer(siteEntitylayers)
            if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { // 判断是否支持图像渲染像素化处理
            // 判断是否支持图像渲染像素化处理
            if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
                global.viewer.setOptions({
                    resolutionScale: window.devicePixelRatio
                })
            }
            // 影像
            // 天地图 影像
            global.viewer.imageryLayers.addImageryProvider(
                new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                    url: 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0',
@@ -75,6 +80,7 @@
            // http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer
            // arcgis服务添加
            global.viewer.imageryLayers.addImageryProvider(
                new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengyjjddom/MapServer/WMTS',
@@ -110,6 +116,7 @@
                })
            )
            // arcgis服务添加
            global.viewer.imageryLayers.addImageryProvider(
                new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer/WMTS',
@@ -166,6 +173,7 @@
            //     })
            // )
            // 设置地图初始位置,角度等
            global.viewer.camera.setView({
                // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                // fromDegrees()方法,将经纬度和高程转换为世界坐标
@@ -187,6 +195,11 @@
        global.DC.ready(initViewer)
    },
    methods: {
        /**
         * 添加农场点及范围的方法
         * @param {*} positions 位置信息(范围信息)
         * @param {*} item 农场对应的所有信息(接口返回的数据)
         */
        addPolygon (positions, item) {
            const that = this
@@ -224,6 +237,11 @@
            }
        },
        /**
         * 添加地块范围的方法
         * @param {*} positions 位置信息(范围信息)
         * @param {*} item 地块对应的所有信息(接口返回的数据)
         */
        addPlotPolygon (positions, item) {
            const that = this
@@ -262,6 +280,11 @@
            addPlotLayers.push({ center, name: item.landName })
        },
        /**
         * 在图层中添加实体(点)
         * @param {*} item 站点(某个设备)对应的所有参数(接口返回对应站点的数据)
         * @param {*} url 图标地址
         */
        addSiteEntity (item, url) {
            const that = this
@@ -305,6 +328,10 @@
            sitePositionsArray.push({ center, name: item.name, id: item.id })
        },
        /**
         * 设置中心点
         * @param {*} name 对应站点(农场范围)的中心点 --- 对应的名字
         */
        setCenter (name) {
            let center
            addLayers.forEach(item => {
@@ -337,6 +364,10 @@
            })
        },
        /**
         * 设置地块中心点
         * @param {*} name 对应站点(地块范围)的中心点 --- 对应的名字
         */
        setPlotCenter (name) {
            let center
            addPlotLayers.forEach(item => {
@@ -361,6 +392,10 @@
            })
        },
        /**
         * 设置中心点
         * @param {*} name 对应站点(设备点)的中心点 --- 对应的名字
         */
        setSiteCenter (name) {
            let center
            sitePositionsArray.forEach(item => {
@@ -387,7 +422,10 @@
            })
        },
        // 经纬度测算中心位置
        /**
         * 根据经纬度范围计算中心点位置
         * @param {*} arr 记录经纬度信息的数组
         */
        getCenter (arr) {
            let centerLonLat = []
            if (arr.length) {