| | |
| | | }); |
| | | }, |
| | | setAddWfsLayer(){ |
| | | this.wfsLayer = earthCtrl.factory.createWfsLayer('polygon', { |
| | | urls: 'https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs', |
| | | layer: 'weapons', |
| | | outlineColor:'#ff0000', |
| | | alpha:0, |
| | | }) |
| | | this.wfsLayer = earthCtrl.factory.createWfsLayer("polygon", { |
| | | urls: "https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs", |
| | | layer: "weapons", |
| | | outlineColor: "#ff0000", |
| | | alpha: 0 |
| | | }); |
| | | }, |
| | | setAddWfsJson() { |
| | | const url = this.getQueryUrl("SubicBayWeapon_wfs", "weapons"); |
| | | |
| | | Cesium.GeoJsonDataSource.load(url, { |
| | | fill: Cesium.Color.fromCssColorString("#FFFFFF00"), |
| | | stroke: Cesium.Color.fromCssColorString("#FFFFFF00"), //多边形或线的颜色 |
| | | |
| | | strokeWidth: 0 //多边形或线 宽度 |
| | | }).then((dataSource) => { |
| | | const entities = dataSource.entities.values; |
| | | entities.map((item) => { |
| | | item.polygon._material.color = |
| | | Cesium.Color.fromCssColorString("#FFFFFF00"); |
| | | |
| | | item.polygon.heightReference = |
| | | Cesium.HeightReference.RELATIVE_TO_GROUND; // 贴地 |
| | | item.polygon.height = 0; // 距地高度0米 |
| | | var polyPositions = item.polygon.hierarchy.getValue().positions; |
| | | var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //中心点 |
| | | polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter); |
| | | item.position = polyCenter; |
| | | let positions = item.polygon.hierarchy._value.positions; |
| | | // 设置面轮廓 |
| | | item.polyline = new Cesium.PolylineGraphics({ |
| | | positions: positions, |
| | | clampToGround: true, // 贴地 |
| | | width: 5, |
| | | material: Cesium.Color.fromCssColorString("#FF0000") |
| | | }); |
| | | console.log(item._name); |
| | | const label_name = item.name ?item.name :""; |
| | | item.label = { |
| | | text: label_name, |
| | | font: "500 16x sans-serif", |
| | | style: Cesium.LabelStyle.FILL_AND_OUTLINE, // 字体样式 |
| | | fillColor: new Cesium.Color.fromCssColorString("#FFFFFF"), |
| | | outlineWidth: 1, // 字体外圈线宽度(同样也有颜色可设置) |
| | | outlineColor: new Cesium.Color.fromCssColorString("#FFFFFF"), |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 垂直位置 |
| | | pixelOffset: new Cesium.Cartesian2(0, 0), // 中心位置 |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition( |
| | | 500.0, |
| | | 3000.0 |
| | | ), |
| | | // showBackground:true, |
| | | // backgroundColor: new Cesium.Color(26 / 255, 196 / 255, 228 / 255, 1.0) //背景顔色 |
| | | }; |
| | | }); |
| | | |
| | | Viewer.dataSources.add(dataSource); |
| | | }); |
| | | }, |
| | | getTileSet() { |
| | | var objItem = mapServer.listData.filter((item) => { |