| | |
| | | const pointEntityMap = new Map(); // key: id, value: entity |
| | | |
| | | export function createPoint(option) { |
| | | const { id, type = "", name = "默认名称", view, latitude, longitude, height, callback, imgWidth = 56, imgHeight = 67, showBillboard = true, showLabel = true, className = "device" } = option; |
| | | const { |
| | | id, |
| | | type = "", |
| | | deviceTypeName = "", |
| | | name = "默认名称", |
| | | view, |
| | | latitude, |
| | | longitude, |
| | | height, |
| | | callback, |
| | | imgWidth = 56, |
| | | imgHeight = 67, |
| | | showBillboard = true, |
| | | showLabel = true, |
| | | className = "device" |
| | | } = option; |
| | | |
| | | |
| | | const realType = type || deviceTypeName; |
| | | |
| | | // 如果已经存在该 id 的 entity,则跳过创建 |
| | | if (pointEntityMap.has(id)) { |
| | | clearAllPoints() |
| | | console.log(`点 ${id} 已存在,跳过创建`); |
| | | // return; |
| | | } |
| | | |
| | | let position = Cesium.Cartesian3.fromDegrees(longitude, latitude, height || 50); |
| | |
| | | id, |
| | | name: name, |
| | | position: position, |
| | | type: type, |
| | | type: realType, |
| | | view: view, |
| | | attrs: option, |
| | | className: className, |
| | | label: { |
| | | text: name || "默认标签", |
| | | font: "14pt Source Han Sans CN", |
| | | fillColor: type.includes("active") ? Cesium.Color.AQUA : Cesium.Color.WHITE, |
| | | fillColor: (typeof realType === 'string' && realType.includes("active")) |
| | | ? Cesium.Color.AQUA |
| | | : Cesium.Color.WHITE, |
| | | // fillColor: Cesium.Color.WHITE, |
| | | backgroundColor: showBillboard ? Cesium.Color.BLACK.withAlpha(0.5) : Cesium.Color.SKYBLUE, |
| | | showBackground: true, |
| | | outline: false, |
| | |
| | | verticalOrigin: Cesium.VerticalOrigin.CENTER, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER, |
| | | pixelOffset: new Cesium.Cartesian2(0, -40), |
| | | distanceDisplayCondition: type.includes("河流") |
| | | distanceDisplayCondition: (typeof realType === 'string' && realType.includes("河流")) |
| | | ? new Cesium.DistanceDisplayCondition(0, 5000000) |
| | | : new Cesium.DistanceDisplayCondition(0, 50000), |
| | | // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 50000), |
| | | heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, |
| | | show: showLabel, |
| | | }, |
| | |
| | | pixelOffset: new Cesium.Cartesian2(0, 3), |
| | | scale: 0.8, |
| | | scaleByDistance: new Cesium.NearFarScalar(1.5e2, 1.0, 1.5e7, 0.5), |
| | | distanceDisplayCondition: type.includes("河流") |
| | | distanceDisplayCondition: (typeof realType === 'string' && realType.includes("河流")) |
| | | ? new Cesium.DistanceDisplayCondition(0, 5000000) |
| | | : new Cesium.DistanceDisplayCondition(0, 50000), |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 50000), |
| | | |
| | | show: showBillboard, |
| | | heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND, |
| | | backgroundColor: showBillboard ? Cesium.Color.BLACK.withAlpha(0.8) : Cesium.Color.SKYBLUE, |