@poor-knight/cesium-utils 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cesium-utils.cjs +17 -17
- package/dist/cesium-utils.js +12 -4
- package/dist/cesium-utils.umd.cjs +17 -17
- package/package.json +1 -1
package/dist/cesium-utils.js
CHANGED
|
@@ -5721,13 +5721,13 @@ function createRoundedRectImage({
|
|
|
5721
5721
|
strokeWidth: o = 2,
|
|
5722
5722
|
// 描边宽度
|
|
5723
5723
|
textColor: d = "#FFFFFF",
|
|
5724
|
-
fontFamily: u = "Segoe UI, Helvetica, Arial, sans-serif",
|
|
5724
|
+
fontFamily: u = "微软雅黑, Segoe UI, Helvetica, Arial, sans-serif",
|
|
5725
5725
|
fontWeight: l = "normal",
|
|
5726
5726
|
fontSize: c = 12,
|
|
5727
5727
|
padding: h = 6,
|
|
5728
5728
|
radius: a = 5
|
|
5729
5729
|
} = {}) {
|
|
5730
|
-
const m = Math.max(0, s.length * c * 0.6 + h * 2), y = c * 1.6, g =
|
|
5730
|
+
const m = Math.max(0, s.length * c * 0.6 + h * 2), y = c * 1.6, g = 2, p = Math.ceil(o / 2) + 1, v = m + p * 2, b = y + p * 2, _ = document.createElement("canvas");
|
|
5731
5731
|
_.width = Math.round(v * g), _.height = Math.round(b * g), _.style.width = `${v}px`, _.style.height = `${b}px`;
|
|
5732
5732
|
const x = _.getContext("2d");
|
|
5733
5733
|
if (!x) throw new Error("无法获取2D绘图上下文");
|
|
@@ -5738,7 +5738,13 @@ function createRoundedRectImage({
|
|
|
5738
5738
|
let A = c;
|
|
5739
5739
|
for (x.fillStyle = d, x.textAlign = "center", x.textBaseline = "middle", x.font = `${l} ${A}px ${u}`; x.measureText(s).width > k && A > 10; )
|
|
5740
5740
|
A -= 1, x.font = `${l} ${A}px ${u}`;
|
|
5741
|
-
return x.fillText(s, v / 2, b / 2), _;
|
|
5741
|
+
return x.fillText(s, v / 2, b / 2 + 1), _;
|
|
5742
|
+
}
|
|
5743
|
+
function hookClusterEvent(s) {
|
|
5744
|
+
s.clustering.clusterEvent.addEventListener((r, o) => {
|
|
5745
|
+
const d = r[0], u = d.billboard, l = d.label, c = d.point;
|
|
5746
|
+
o.label.show = !1, o.point.show = !1, u && (o.billboard = Cesium.clone(u)), l && (o.label = Cesium.clone(l)), c ? o.point = Cesium.clone(c) : (o.billboard.show = !0, o.billboard.image = Cesium.buildModuleUrl("Widgets/Images/clusterIcon.png"));
|
|
5747
|
+
});
|
|
5742
5748
|
}
|
|
5743
5749
|
class ShipLayer extends EventEmitter {
|
|
5744
5750
|
constructor(r, o, d) {
|
|
@@ -5753,7 +5759,7 @@ class ShipLayer extends EventEmitter {
|
|
|
5753
5759
|
j(this, "shadowEntityMap", /* @__PURE__ */ new WeakMap());
|
|
5754
5760
|
/**显隐entity,回调返回显示隐藏的状态,不传Fn时默认显示所有 */
|
|
5755
5761
|
j(this, "hookFilterEntityFn");
|
|
5756
|
-
this.key = r, this.zIndex = o, this.db = new Cesium.CustomDataSource(r), this.labelDataSource.clustering.enabled = ((u = d == null ? void 0 : d.clustering) == null ? void 0 : u.enabled) ?? !0, this.labelDataSource.clustering.pixelRange = ((l = d == null ? void 0 : d.clustering) == null ? void 0 : l.pixelRange) ?? 15, this.labelDataSource.clustering.minimumClusterSize = ((c = d == null ? void 0 : d.clustering) == null ? void 0 : c.minimumClusterSize) ?? 2;
|
|
5762
|
+
this.key = r, this.zIndex = o, this.db = new Cesium.CustomDataSource(r), this.labelDataSource.clustering.enabled = ((u = d == null ? void 0 : d.clustering) == null ? void 0 : u.enabled) ?? !0, this.labelDataSource.clustering.pixelRange = ((l = d == null ? void 0 : d.clustering) == null ? void 0 : l.pixelRange) ?? 15, this.labelDataSource.clustering.minimumClusterSize = ((c = d == null ? void 0 : d.clustering) == null ? void 0 : c.minimumClusterSize) ?? 2, hookClusterEvent(this.labelDataSource);
|
|
5757
5763
|
}
|
|
5758
5764
|
show(r) {
|
|
5759
5765
|
this.isMounted || (r.dataSources.add(this.db), r.dataSources.add(this.labelDataSource), this._viewer = r, this.isMounted = !0), this.db.show = !0;
|
|
@@ -5907,6 +5913,8 @@ class ShipLayer extends EventEmitter {
|
|
|
5907
5913
|
const o = (h = r.properties) == null ? void 0 : h.getValue(), d = o != null && o.updateTime ? new Date(o.updateTime) : /* @__PURE__ */ new Date(), u = Cesium.JulianDate.fromDate(d), l = ((m = (a = r.properties) == null ? void 0 : a.getValue()) == null ? void 0 : m.name) ?? ((y = r.properties) != null && y.getValue().mmsi ? "mmsi:" + ((g = r.properties) == null ? void 0 : g.getValue().mmsi) : "未知"), c = createRoundedRectImage({ text: l });
|
|
5908
5914
|
r.billboard = new Cesium.BillboardGraphics({
|
|
5909
5915
|
image: new Cesium.ConstantProperty(c),
|
|
5916
|
+
width: new Cesium.ConstantProperty(Number(c.style.width.replace("px", ""))),
|
|
5917
|
+
height: new Cesium.ConstantProperty(Number(c.style.height.replace("px", ""))),
|
|
5910
5918
|
scale: new Cesium.ConstantProperty(1),
|
|
5911
5919
|
// 根据需要微调偏移,让文本位于正中心
|
|
5912
5920
|
pixelOffset: new Cesium.ConstantProperty(new Cesium.Cartesian2(0, -20)),
|