|
@@ -107,7 +107,6 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { test } from "shelljs";
|
|
|
import drawData from "./draw.json";
|
|
|
import ghjgData from "./规划结果.json";
|
|
|
export default {
|
|
@@ -193,138 +192,13 @@ export default {
|
|
|
mounted() {
|
|
|
console.log(drawData, "drawData", ghjgData);
|
|
|
this.init_hyqy();
|
|
|
- // ghjgData.features.forEach((el,i) =>{
|
|
|
- // this.creatPolyGon(el)
|
|
|
- // })
|
|
|
- this.test();
|
|
|
+ this.addGeoJson();
|
|
|
},
|
|
|
methods: {
|
|
|
- test() {
|
|
|
- ghjgData.features.forEach((res) => {
|
|
|
- let obj = {
|
|
|
- // type: "cockpit",
|
|
|
- type: "Feature",
|
|
|
- name: res.properties.kzxxgydmc,
|
|
|
- ydmj: res.properties.ydmj,
|
|
|
- // centroid: res.properties.centroid,
|
|
|
- // adcode: res.properties.adcode,
|
|
|
- };
|
|
|
- res.geometry.coordinates.forEach((item) => {
|
|
|
- const twoDArray = item[0];
|
|
|
- const oneDArray = twoDArray.reduce(
|
|
|
- (accumulator, currentValue) => accumulator.concat(currentValue),
|
|
|
- []
|
|
|
- );
|
|
|
-
|
|
|
- viewer.entities.add({
|
|
|
- // position: Cesium.Cartesian3.fromDegrees(
|
|
|
- // obj.centroid[0],
|
|
|
- // res.properties.centroid[1],
|
|
|
- // 100
|
|
|
- // ),
|
|
|
- text: obj.name,
|
|
|
- label: {
|
|
|
- scale: 1.5,
|
|
|
- font: "bolder 16px sans-serif",
|
|
|
- style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
|
- text: res.properties.ydmj, //图标名称
|
|
|
- fillColor: Cesium.Color.fromCssColorString("#ffffff"),
|
|
|
- pixelOffset: new Cesium.Cartesian2(5, -15),
|
|
|
- zIndex: 3,
|
|
|
- // 设置远近裁条件
|
|
|
- distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- 20000,
|
|
|
- 9999999999.0
|
|
|
- ),
|
|
|
- },
|
|
|
- // billboard: {
|
|
|
- // // 图像地址,URI或Canvas的属性
|
|
|
- // image: "./static/images/overview/htq-f.png",
|
|
|
- // height: 60,
|
|
|
- // // 宽度(以像素为单位)
|
|
|
- // width: 150,
|
|
|
- // // 相对于坐标的垂直位置
|
|
|
- // // verticalOrigin: Cesium.VerticalOrigin.CENTER,
|
|
|
- // // // 相对于坐标的水平位置
|
|
|
- // // horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
|
- // scale: 1.0,
|
|
|
- // zIndex: 2,
|
|
|
- // // 设置远近裁条件
|
|
|
- // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- // 20000,
|
|
|
- // 9999999999.0
|
|
|
- // ),
|
|
|
- // show: true,
|
|
|
- // },
|
|
|
- properties: obj,
|
|
|
- polygon: {
|
|
|
- zIndex: 1,
|
|
|
- hierarchy: {
|
|
|
- positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
|
|
|
- },
|
|
|
- // outline: false,
|
|
|
- // material: Cesium.Color.fromCssColorString(this.xzqh_color),
|
|
|
- height: 100,
|
|
|
- // extrudedHeight: res.properties.extrudedHeight,
|
|
|
- material: Cesium.Color.WHITE.withAlpha(0.2),
|
|
|
- outline: true,
|
|
|
- outlineWidth: 3,
|
|
|
- outlineColor: Cesium.Color.fromCssColorString("#4B93E0"), // 设置远近裁条件
|
|
|
- // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
|
|
|
- // 20000,
|
|
|
- // 9999999999.0
|
|
|
- // ),
|
|
|
- },
|
|
|
- });
|
|
|
-
|
|
|
- // let polygon = new Cesium.GeometryInstance({
|
|
|
- // geometry: new Cesium.PolygonGeometry({
|
|
|
- // polygonHierarchy: new Cesium.PolygonHierarchy(
|
|
|
- // Cesium.Cartesian3.fromDegreesArray(oneDArray)
|
|
|
- // ),
|
|
|
- // height: 100,
|
|
|
- // extrudedHeight: res.properties.extrudedHeight,
|
|
|
-
|
|
|
- // })
|
|
|
- // })
|
|
|
-
|
|
|
- // let addPolygonGeometry = new Cesium.Primitive({
|
|
|
- // geometryInstances: polygon,
|
|
|
- // appearance: this.colorFun(Cesium.Color.fromCssColorString("rgba(254, 129, 6, 0.1)"))
|
|
|
-
|
|
|
- // })
|
|
|
-
|
|
|
- // viewer.scene.primitives.add(addPolygonGeometry)
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- creatPolyGon(item) {
|
|
|
- let obj = {
|
|
|
- type: item.type,
|
|
|
- name: item.properties.kzxxgydmc || "ceshi",
|
|
|
- };
|
|
|
- const twoDArray = item.geometry.coordinates[0][0];
|
|
|
- const oneDArray = twoDArray.reduce(
|
|
|
- (accumulator, currentValue) => accumulator.concat(currentValue),
|
|
|
- []
|
|
|
+ addGeoJson() {
|
|
|
+ viewer.dataSources.add(
|
|
|
+ Cesium.GeoJsonDataSource.load("static/data/规划结果.json")
|
|
|
);
|
|
|
-
|
|
|
- viewer.entities.add({
|
|
|
- // position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
|
|
|
- properties: obj,
|
|
|
- name: item.properties.kzxxgydmc || "ceshi",
|
|
|
- polygon: {
|
|
|
- hierarchy: {
|
|
|
- positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
|
|
|
- },
|
|
|
- material: Cesium.Color.WHITE.withAlpha(0.2),
|
|
|
- height: 100,
|
|
|
- outline: true,
|
|
|
- outlineWidth: 3,
|
|
|
- outlineColor: Cesium.Color.fromCssColorString("#4B93E0"),
|
|
|
- },
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
init_hyqy() {
|