|
@@ -149,6 +149,7 @@ import { WriteWkt, DownFile } from "@/api/cockpitNew";
|
|
|
|
|
|
// 使用
|
|
|
import parse from "wellknown";
|
|
|
+import * as turf from "@turf/turf";
|
|
|
let dataSources = {};
|
|
|
export default {
|
|
|
components: { dkDetails },
|
|
@@ -348,10 +349,12 @@ export default {
|
|
|
entity.polygon.outlineColor = Cesium.Color.BLACK;
|
|
|
entity.polygon.outlineWidth = 1.0;
|
|
|
if (!addlabel) {
|
|
|
+ let center = this.getCentroid(geojson).geometry.coordinates;
|
|
|
+ console.log(center, "geojson");
|
|
|
var polycenter = Cesium.Cartesian3.fromDegrees(
|
|
|
- geojson.coordinates[0][0][0],
|
|
|
- geojson.coordinates[0][0][1],
|
|
|
- 100
|
|
|
+ center[0],
|
|
|
+ center[1],
|
|
|
+ height
|
|
|
);
|
|
|
entity.position = polycenter;
|
|
|
entity.label = {
|
|
@@ -359,7 +362,7 @@ export default {
|
|
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
|
|
text: name, //图标名称
|
|
|
fillColor: Cesium.Color.fromCssColorString("#fff000"),
|
|
|
- pixelOffset: new Cesium.Cartesian2(5, -15),
|
|
|
+ pixelOffset: new Cesium.Cartesian2(0, -20),
|
|
|
zIndex: 3,
|
|
|
};
|
|
|
addlabel = true;
|
|
@@ -379,6 +382,20 @@ export default {
|
|
|
if (id == "all") _this.isshowAll = true;
|
|
|
});
|
|
|
},
|
|
|
+ getCentroid(geojson) {
|
|
|
+ console.log(geojson, "jj");
|
|
|
+ if (turf.getType(geojson) === "Feature") {
|
|
|
+ geojson = geojson.geometry;
|
|
|
+ }
|
|
|
+ if (turf.getType(geojson) === "Polygon") {
|
|
|
+ return turf.centroid(geojson);
|
|
|
+ } else if (turf.getType(geojson) === "MultiPolygon") {
|
|
|
+ let polygon = turf.polygon(geojson.coordinates[0]);
|
|
|
+ return turf.centroid(polygon);
|
|
|
+ } else {
|
|
|
+ throw new Error("Unsupported geometry type");
|
|
|
+ }
|
|
|
+ },
|
|
|
addprogramme(e, item) {
|
|
|
e.stopPropagation();
|
|
|
const list = this.bgList.filter((item1) => {
|
|
@@ -426,7 +443,7 @@ export default {
|
|
|
viewer.flyTo(dataSources[upid], {
|
|
|
offset: new Cesium.HeadingPitchRange(0, -0.8, 3000),
|
|
|
});
|
|
|
- else this.mapview(item)
|
|
|
+ else this.mapview(item);
|
|
|
},
|
|
|
|
|
|
deleteprogramme(e, item) {
|