|
@@ -71,10 +71,12 @@ export default {
|
|
|
methods: {
|
|
|
eyesChaneg(i) {
|
|
|
this.echarts[i].iseyes = !this.echarts[i].iseyes;
|
|
|
- let item = this.echarts[i];
|
|
|
- if (this.dataSources[item.id]) {
|
|
|
- this.dataSources[item.id].show = item.iseyes;
|
|
|
- } else this.addPolygon(item);
|
|
|
+ let label = this.echarts[i].label;
|
|
|
+ let id = "scjg" + i;
|
|
|
+ console.log("----", this.dataSources, id);
|
|
|
+ if (this.dataSources[id]) {
|
|
|
+ this.dataSources[id].show = item.iseyes;
|
|
|
+ } else this.addPolygon(label, id);
|
|
|
// emit("eyesChaneg");
|
|
|
},
|
|
|
setEchart1() {
|
|
@@ -98,19 +100,21 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 加载GeoJSON数据
|
|
|
- addPolygon({ label, id }) {
|
|
|
- viewer.entities.removeAll();
|
|
|
+ addPolygon(label, id) {
|
|
|
+ let _this = this;
|
|
|
+ // viewer.entities.removeAll();
|
|
|
let polygon = Cesium.GeoJsonDataSource.load(
|
|
|
`/static/data/ghss/${label}.geojson`,
|
|
|
{ clampToGround: true }
|
|
|
);
|
|
|
polygon.then(function (dataSource) {
|
|
|
- this.dataSources[id] = dataSource;
|
|
|
+ console.log("----", _this);
|
|
|
// dataSource.id = id;
|
|
|
// 将数据源添加到Cesium Viewer
|
|
|
viewer.dataSources.add(dataSource);
|
|
|
viewer.zoomTo(dataSource);
|
|
|
-
|
|
|
+ _this.dataSources[id] = dataSource;
|
|
|
+ console.log(_this.dataSources);
|
|
|
// 可以获取实体并进行操作
|
|
|
// dataSource.entities.values.forEach((entity) => {
|
|
|
// // 你可以在这里设置实体的属性,例如位置、颜色等
|