| | |
| | | var source = [] |
| | | import { Grid_SelectById } from '@/api/api' |
| | | import { Grid_SelectById ,Grid_DeleteByIds} from '@/api/api' |
| | | const mapGeo = { |
| | | source1: null, |
| | | type: null, |
| | | feature: [], |
| | | gridId: null, |
| | | init(res) { |
| | | if (this.type && this.type === res) { |
| | | return this.type = null |
| | |
| | | }, |
| | | addGridLayer(res) { |
| | | var ids = res.style.ids; |
| | | var length = ids.length ; |
| | | |
| | | var length = ids.length; |
| | | if (res.id == this.gridId) { |
| | | this.gridId = null; |
| | | return |
| | | } |
| | | this.gridId = res.id; |
| | | this.feature = []; |
| | | for (var i = 0; i < length; i++) { |
| | | this.getGridids(ids[i], length-1, i); |
| | | this.getGridids(ids[i], length); |
| | | } |
| | | }, |
| | | delGridLayer(res) { |
| | | if(!res)return |
| | | Viewer.dataSources.remove(Viewer.dataSources.getByName(res.id)[0]) |
| | | }, |
| | | removeGridData(res) { |
| | | this.delGridLayer(res); |
| | | var ids = res.style.ids; |
| | | for (var i = 0; i < ids.length; i++) { |
| | | this.delGridIds(ids[i]); |
| | | } |
| | | }, |
| | | async delGridIds(res) { |
| | | console.log(res) |
| | | const data = await Grid_DeleteByIds(res); |
| | | }, |
| | | 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, |
| | | var val_data = data.data.features[0]; |
| | | val_data.properties["gid"] = id; |
| | | this.feature.push(val_data) |
| | | if (this.feature.length == length) { |
| | | var feature = { |
| | | "type": "FeatureCollection", |
| | | "name": "wangge", |
| | | "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, |
| | | "features": this.feature, |
| | | } |
| | | |
| | | this.addGridMenuGeoJson(feature) |
| | | } |
| | | console.log(feature); |
| | | this.addGridMenuGeoJson(feature) |
| | | } |
| | | |
| | | |
| | | }, |
| | | addGridMenuGeoJson(res){ |
| | | console.log(res); |
| | | addGridMenuGeoJson(res) { |
| | | var data = Cesium.GeoJsonDataSource.load(res, //要加载的 url、GeoJSON 对象或 TopoJSON 对象。 |
| | | { |
| | | stroke: Cesium.Color.ORANGE, //折线和多边形轮廓的默认颜色。 |
| | |
| | | } |
| | | ) |
| | | data.then((dataSource) => { |
| | | dataSource.name = "格网" |
| | | dataSource.name = this.gridId; |
| | | Viewer.dataSources.add( |
| | | dataSource |
| | | ); |