修改地图加载细节
This commit is contained in:
@@ -270,17 +270,15 @@ export class CesiumUtils {
|
||||
* 批量添加GeoJSON图层
|
||||
* @param layerIds - 图层 ID 数组
|
||||
* @param geojsonDatas - GeoJSON 数据数组
|
||||
* @param isDefaults - 是否为默认图层数组
|
||||
* @param options - 配置选项数组
|
||||
* @param options - 配置选项数组(包含 isDefault)
|
||||
*/
|
||||
async batchAddGeoJsonLayers(
|
||||
layerIds: string[],
|
||||
geojsonDatas: CustomizeGeoJsonDataSource[],
|
||||
isDefaults: boolean[],
|
||||
options?: GeoJsonOptions[]
|
||||
): Promise<void> {
|
||||
this.#checkManager(this.#geoJsonManager, 'GeoJsonManager')
|
||||
await this.#geoJsonManager!.batchAddGeoJsonLayers(layerIds, geojsonDatas, isDefaults, options)
|
||||
await this.#geoJsonManager!.batchAddGeoJsonLayers(layerIds, geojsonDatas, options)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ export class EntityManager {
|
||||
* @returns 创建的 Entity 实例
|
||||
*/
|
||||
addCesiumEntity(entityOptions: EntityOptions): Entity {
|
||||
const { id, position, attributes = {}, default: isDefault = false } = entityOptions
|
||||
const { id, position, attributes = {}, isDefault = false } = entityOptions
|
||||
|
||||
if (!id) throw new Error('实体 id 为必填项')
|
||||
if (!position) throw new Error('实体 position 为必填项')
|
||||
|
||||
@@ -32,7 +32,7 @@ export class GeoJsonManager {
|
||||
// 默认配置
|
||||
static readonly DEFAULT_OPTIONS: Required<GeoJsonOptions> = {
|
||||
showName: false,
|
||||
default: false,
|
||||
isDefault: false,
|
||||
labelStyle: {
|
||||
labelFont: '16px "微软雅黑"',
|
||||
labelColor: Color.RED,
|
||||
@@ -84,8 +84,7 @@ export class GeoJsonManager {
|
||||
if (this.#exists(layerId)) throw new Error(`图层 ${layerId} 已存在`)
|
||||
const opt = this.#mergeOptions(options)
|
||||
|
||||
// 优先使用 isDefault 参数,其次使用 options.default
|
||||
const finalIsDefault = isDefault || opt.default
|
||||
const finalIsDefault = isDefault || opt.isDefault
|
||||
|
||||
// 加载并应用样式
|
||||
const dataSource = await GeoJsonDataSource.load(geojsonData)
|
||||
@@ -146,18 +145,16 @@ export class GeoJsonManager {
|
||||
* 批量添加GeoJSON图层
|
||||
* @param layerIds - 图层 ID 数组
|
||||
* @param geojsonDatas - GeoJSON 数据数组
|
||||
* @param isDefaults - 是否为默认图层数组
|
||||
* @param options - 配置选项数组
|
||||
* @param options - 配置选项数组(包含 isDefault)
|
||||
*/
|
||||
async batchAddGeoJsonLayers(
|
||||
layerIds: string[],
|
||||
geojsonDatas: CustomizeGeoJsonDataSource[],
|
||||
isDefaults: boolean[],
|
||||
options?: GeoJsonOptions[],
|
||||
): Promise<void> {
|
||||
await Promise.all(
|
||||
layerIds.map((id, index) =>
|
||||
this.addGeoJsonLayer(id, geojsonDatas?.[index], isDefaults?.[index], options?.[index])
|
||||
this.addGeoJsonLayer(id, geojsonDatas?.[index], false, options?.[index])
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class LayerManager {
|
||||
* @returns 创建的 ImageryLayer 实例,失败则返回 null
|
||||
*/
|
||||
createLayer(layerConfig: LayerConfig): ImageryLayer | null {
|
||||
const { layers: layerKey, default: isDefault = false } = layerConfig
|
||||
const { layers: layerKey, isDefault = false } = layerConfig
|
||||
|
||||
if (!layerKey) throw new Error('layers 参数未定义')
|
||||
this.#validateUniqueLayerKey(layerKey)
|
||||
|
||||
@@ -251,7 +251,7 @@ export class PrimitiveManager {
|
||||
|
||||
#storePrimitives(options: PrimitiveOptions[], primitive: Primitive | BillboardCollection): void {
|
||||
options.forEach((option) => {
|
||||
if (option.default) {
|
||||
if (option.isDefault) {
|
||||
this.#defaultPrimitiveMap.set(option.id, primitive)
|
||||
} else {
|
||||
this.#customPrimitiveMap.set(option.id, primitive)
|
||||
|
||||
Reference in New Issue
Block a user