|
@@ -139,6 +139,8 @@ import windPro from "@/components/windProDetail/windProblem.vue";
|
|
|
import cesiumwindView from "./cesiumComponents/cesiumwindView.vue";
|
|
import cesiumwindView from "./cesiumComponents/cesiumwindView.vue";
|
|
|
import timeControl from "@/components/timeControl/index.vue";
|
|
import timeControl from "@/components/timeControl/index.vue";
|
|
|
|
|
|
|
|
|
|
+import * as turf from "@turf/turf";
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
name: "CesiumMap",
|
|
name: "CesiumMap",
|
|
|
|
|
|
|
@@ -233,9 +235,12 @@ export default {
|
|
|
controlMode: "",
|
|
controlMode: "",
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
created() {
|
|
created() {
|
|
|
this.getWeatherData();
|
|
this.getWeatherData();
|
|
|
|
|
+ // console.log(1111, this.findLocation(109.6429758178942, 34.10868446715471));
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
mounted() {
|
|
mounted() {
|
|
|
this.initEventListener();
|
|
this.initEventListener();
|
|
|
this.initCesium();
|
|
this.initCesium();
|
|
@@ -257,6 +262,60 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ // 传入经纬度,获取经纬度所在的行政区信息
|
|
|
|
|
+ findLocation(lng, lat) {
|
|
|
|
|
+ const point = turf.point([lng, lat]);
|
|
|
|
|
+ let foundProvince = null;
|
|
|
|
|
+ let foundCity = null;
|
|
|
|
|
+
|
|
|
|
|
+ // 遍历所有要素查找包含点的多边形
|
|
|
|
|
+ for (const feature of basicGeoJson.features) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (
|
|
|
|
|
+ feature.geometry &&
|
|
|
|
|
+ turf.booleanPointInPolygon(point, feature.geometry)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ const properties = feature.properties;
|
|
|
|
|
+
|
|
|
|
|
+ // 根据你的GeoJSON结构调整属性名
|
|
|
|
|
+ // 常见的有:name, NAME, 省, 市, province, city等
|
|
|
|
|
+ const province =
|
|
|
|
|
+ properties.province || properties.省 || properties.name;
|
|
|
|
|
+ const city = properties.city || properties.市 || properties.name;
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是省级数据(没有city属性)
|
|
|
|
|
+ if (city === province || !properties.city) {
|
|
|
|
|
+ if (!foundProvince) {
|
|
|
|
|
+ foundProvince = {
|
|
|
|
|
+ province: province,
|
|
|
|
|
+ adcode: properties.adcode || properties.code,
|
|
|
|
|
+ geometry: feature.geometry,
|
|
|
|
|
+ properties: properties,
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 市级数据
|
|
|
|
|
+ foundCity = {
|
|
|
|
|
+ province: province,
|
|
|
|
|
+ city: city,
|
|
|
|
|
+ adcode: properties.adcode || properties.code,
|
|
|
|
|
+ geometry: feature.geometry,
|
|
|
|
|
+ properties: properties,
|
|
|
|
|
+ };
|
|
|
|
|
+ break; // 找到市级就停止
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.warn("处理要素时出错:", error);
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const result = foundCity || foundProvince;
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
changeType(value) {
|
|
changeType(value) {
|
|
|
this.stationValue = value;
|
|
this.stationValue = value;
|
|
|
this.allStationentitys.forEach(({ entity, handler }) => {
|
|
this.allStationentitys.forEach(({ entity, handler }) => {
|
|
@@ -401,7 +460,9 @@ export default {
|
|
|
|
|
|
|
|
// 隐藏 Cesium Logo
|
|
// 隐藏 Cesium Logo
|
|
|
viewer.cesiumWidget.creditContainer.style.display = "none";
|
|
viewer.cesiumWidget.creditContainer.style.display = "none";
|
|
|
- viewer.scene.globe.baseColor = Cesium.Color.BLACK;
|
|
|
|
|
|
|
+ viewer.scene.globe.baseColor = new Cesium.Color.fromCssColorString(
|
|
|
|
|
+ "#1890ff"
|
|
|
|
|
+ );
|
|
|
// 禁用 Viewer 默认的双击缩放
|
|
// 禁用 Viewer 默认的双击缩放
|
|
|
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
|
|
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
|
|
|
Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
|
|
Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
|
|
@@ -413,7 +474,7 @@ export default {
|
|
|
|
|
|
|
|
// this.setMapImageryProvider();
|
|
// this.setMapImageryProvider();
|
|
|
// this.initCesiumTerrain();
|
|
// this.initCesiumTerrain();
|
|
|
- this.initCesiumBaseMapImage();
|
|
|
|
|
|
|
+ // this.initCesiumBaseMapImage();
|
|
|
// this.switchWindLayer();
|
|
// this.switchWindLayer();
|
|
|
this.showAllStation(viewer, allStationJson.station);
|
|
this.showAllStation(viewer, allStationJson.station);
|
|
|
this.initGeoJsonData();
|
|
this.initGeoJsonData();
|
|
@@ -928,7 +989,7 @@ export default {
|
|
|
|
|
|
|
|
entity.polyline = {
|
|
entity.polyline = {
|
|
|
positions: positions,
|
|
positions: positions,
|
|
|
- width: 2,
|
|
|
|
|
|
|
+ width: 0.5,
|
|
|
outline: false,
|
|
outline: false,
|
|
|
// clampToGround: true,
|
|
// clampToGround: true,
|
|
|
show: true,
|
|
show: true,
|