surprise
2024-01-10 2a960cd2c5b88b143cea4acfaeafb96daef0f29b
src/assets/js/Layer/mapGeo.js
@@ -1,7 +1,9 @@
var source = []
import { Grid_SelectById } from '@/api/api'
const mapGeo = {
    source1: null,
    type: null,
    feature: [],
    init(res) {
        if (this.type && this.type === res) {
            return this.type = null
@@ -28,7 +30,48 @@
                break;
        }
    },
    addGridLayer(res) {
        var ids = res.style.ids;
        var length = ids.length ;
        this.feature = [];
        for (var i = 0; i < length; i++) {
            this.getGridids(ids[i], length-1, i);
        }
    },
    async getGridids(id, length, index) {
        const data = await Grid_SelectById(id)
        if (data.status == 200) {
            this.feature.push(data.data.features[0])
        }
        console.log(index,length)
        if (index == length) {
            var feature = {
                "type": "FeatureCollection",
                "name": "wangge",
                "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
                "features": this.feature,
            }
            console.log(feature);
            this.addGridMenuGeoJson(feature)
        }
    },
    addGridMenuGeoJson(res){
        console.log(res);
        var data = Cesium.GeoJsonDataSource.load(res, //要加载的 url、GeoJSON 对象或 TopoJSON 对象。
            {
                stroke: Cesium.Color.ORANGE, //折线和多边形轮廓的默认颜色。
                fill: Cesium.Color.WHITE.withAlpha(0.2), //多边形内部的默认颜色。
                strokeWidth: 3, //折线和多边形轮廓的默认宽度。
            }
        )
        data.then((dataSource) => {
            dataSource.name = "格网"
            Viewer.dataSources.add(
                dataSource
            );
        })
    },
    addZhongPoGeoJson(res) {
        var url = layerData.config.Model_URL + res.urls;
        var data = Cesium.GeoJsonDataSource.load(url, //要加载的 url、GeoJSON 对象或 TopoJSON 对象。
@@ -49,16 +92,16 @@
        if (this.type && this.type == res) {
            this.type = null
        }
            if (!res.type) return;
            Viewer.dataSources.remove(Viewer.dataSources.getByName(res.type)[0])
        if (!res.type) return;
        Viewer.dataSources.remove(Viewer.dataSources.getByName(res.type)[0])
    },
    addzhaiHaiGeoJson(res) {
        var url1 = layerData.config.Model_URL + res.urls ;
        var url1 = layerData.config.Model_URL + res.urls;
        var color = Cesium.Color.fromCssColorString("rgb(255,0,255)")
        var data1 = Cesium.GeoJsonDataSource.load(url1, //要加载的 url、GeoJSON 对象或 TopoJSON 对象。
            {
@@ -74,7 +117,7 @@
            );
        })
    },
    addZhongQuXianGeoJson(res) {