cesium-xs-sdk 1.0.10 → 1.0.11
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-xs-sdk.cjs.js +53 -14
- package/dist/cesium-xs-sdk.cjs.js.map +1 -1
- package/dist/cesium-xs-sdk.esm.js +53 -14
- package/dist/cesium-xs-sdk.esm.js.map +1 -1
- package/dist/cesium-xs-sdk.umd.js +1 -1
- package/dist/cesium-xs-sdk.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/core/Config.js +4 -0
- package/src/index.d.ts +3 -0
- package/src/modules/MilitarySymbolModule.js +49 -14
|
@@ -95,6 +95,10 @@ class Config {
|
|
|
95
95
|
navigationInstructionsInitiallyVisible: false,
|
|
96
96
|
depthTestAgainstTerrain: true, // 默认开启深度检测
|
|
97
97
|
},
|
|
98
|
+
// 军标模块默认配置
|
|
99
|
+
militarySymbol: {
|
|
100
|
+
defaultIconMode: 'default', // 'default' | 'custom' | 'overlay'
|
|
101
|
+
},
|
|
98
102
|
// 图元默认样式:延迟到 getConfig 时再构造,避免在 Cesium 未配置时崩溃
|
|
99
103
|
// (对 SSR 和单元测试更友好)
|
|
100
104
|
};
|
|
@@ -9240,6 +9244,39 @@ class MilitarySymbolModule {
|
|
|
9240
9244
|
return this;
|
|
9241
9245
|
}
|
|
9242
9246
|
|
|
9247
|
+
/**
|
|
9248
|
+
* 设置全局默认图标模式
|
|
9249
|
+
* @param {'default'|'custom'|'overlay'} mode 默认图标模式
|
|
9250
|
+
* @returns {MilitarySymbolModule}
|
|
9251
|
+
*/
|
|
9252
|
+
setDefaultIconMode(mode) {
|
|
9253
|
+
this._defaultIconMode = mode;
|
|
9254
|
+
return this;
|
|
9255
|
+
}
|
|
9256
|
+
|
|
9257
|
+
/**
|
|
9258
|
+
* 注册某个军标类型的默认图标
|
|
9259
|
+
* @param {string} type 军标类型
|
|
9260
|
+
* @param {string} imgUrl 图标 URL / dataURL
|
|
9261
|
+
* @returns {MilitarySymbolModule}
|
|
9262
|
+
*/
|
|
9263
|
+
registerDefaultImage(type, imgUrl) {
|
|
9264
|
+
this.defaultImageMap.set(type, imgUrl);
|
|
9265
|
+
return this;
|
|
9266
|
+
}
|
|
9267
|
+
|
|
9268
|
+
/**
|
|
9269
|
+
* 批量注册军标默认图标
|
|
9270
|
+
* @param {Record<string, string>} map { type: imgUrl }
|
|
9271
|
+
* @returns {MilitarySymbolModule}
|
|
9272
|
+
*/
|
|
9273
|
+
registerDefaultImages(map) {
|
|
9274
|
+
Object.entries(map).forEach(([type, imgUrl]) => {
|
|
9275
|
+
this.registerDefaultImage(type, imgUrl);
|
|
9276
|
+
});
|
|
9277
|
+
return this;
|
|
9278
|
+
}
|
|
9279
|
+
|
|
9243
9280
|
/**
|
|
9244
9281
|
* 解析军标图标
|
|
9245
9282
|
* - iconMode = 'default':使用 SDK 内置默认图标;没有默认图标时回退到 imgUrl
|
|
@@ -9248,23 +9285,27 @@ class MilitarySymbolModule {
|
|
|
9248
9285
|
* @private
|
|
9249
9286
|
*/
|
|
9250
9287
|
_resolveImage(id, options) {
|
|
9251
|
-
const
|
|
9288
|
+
const globalMode = this._defaultIconMode || this.config.militarySymbol?.defaultIconMode;
|
|
9289
|
+
const mode = options.iconMode || globalMode || 'default';
|
|
9252
9290
|
const defaultImage = DEFAULT_SYMBOL_IMAGES[options.type];
|
|
9291
|
+
const registeredImage = this.defaultImageMap.get(options.type);
|
|
9292
|
+
const imgUrl = options.imgUrl || registeredImage || null;
|
|
9253
9293
|
|
|
9254
9294
|
if (mode === 'custom') {
|
|
9255
|
-
if (!
|
|
9256
|
-
console.warn(`iconMode 为 custom
|
|
9295
|
+
if (!imgUrl) {
|
|
9296
|
+
console.warn(`iconMode 为 custom 时未找到可用图标,将尝试使用默认图标`);
|
|
9257
9297
|
return defaultImage || null;
|
|
9258
9298
|
}
|
|
9259
|
-
return
|
|
9299
|
+
return imgUrl;
|
|
9260
9300
|
}
|
|
9261
9301
|
|
|
9262
9302
|
if (mode === 'overlay') {
|
|
9263
|
-
|
|
9264
|
-
|
|
9303
|
+
const overlayImage = imgUrl;
|
|
9304
|
+
if (!overlayImage || !defaultImage) {
|
|
9305
|
+
return overlayImage || defaultImage || null;
|
|
9265
9306
|
}
|
|
9266
9307
|
// 异步合成叠加图标,创建时先返回默认图标,合成完成后再替换
|
|
9267
|
-
this._composeOverlayImage(defaultImage,
|
|
9308
|
+
this._composeOverlayImage(defaultImage, overlayImage).then((compositeUrl) => {
|
|
9268
9309
|
const symbol = this.symbolMap.get(id);
|
|
9269
9310
|
if (symbol?.entity?.billboard) {
|
|
9270
9311
|
symbol.entity.billboard.image = compositeUrl;
|
|
@@ -9275,13 +9316,11 @@ class MilitarySymbolModule {
|
|
|
9275
9316
|
return defaultImage;
|
|
9276
9317
|
}
|
|
9277
9318
|
|
|
9278
|
-
//
|
|
9279
|
-
if (
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
}
|
|
9284
|
-
return defaultImage;
|
|
9319
|
+
// 默认模式:优先 SDK 内置图标,其次注册图标 / imgUrl
|
|
9320
|
+
if (defaultImage) return defaultImage;
|
|
9321
|
+
if (imgUrl) return imgUrl;
|
|
9322
|
+
console.warn(`军标类型 ${options.type} 未提供图标,也未找到内置默认图标`);
|
|
9323
|
+
return null;
|
|
9285
9324
|
}
|
|
9286
9325
|
|
|
9287
9326
|
/**
|