修改添加gsojson的isdefault,方便重置场景
This commit is contained in:
@@ -19,9 +19,9 @@
|
|||||||
const layerConfigs = areasId.map((id, index) => ({
|
const layerConfigs = areasId.map((id, index) => ({
|
||||||
layerId: id,
|
layerId: id,
|
||||||
geojsonData: areas[index],
|
geojsonData: areas[index],
|
||||||
isDefault: true,
|
|
||||||
options: {
|
options: {
|
||||||
showName: true,
|
showName: true,
|
||||||
|
isDefault: true,
|
||||||
labelStyle: {
|
labelStyle: {
|
||||||
labelText: areas[index].features[0].properties.name,
|
labelText: areas[index].features[0].properties.name,
|
||||||
center: [
|
center: [
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
:get-disaster-icon="getDisasterIcon"
|
:get-disaster-icon="getDisasterIcon"
|
||||||
:prefix="config.prefix.hiddenDangerPointId"
|
:prefix="config.prefix.hiddenDangerPointId"
|
||||||
:show-points="useStatusStore().getHiddenDangerPointShow()"
|
:show-points="useStatusStore().getHiddenDangerPointShow()"
|
||||||
|
:is-default="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 显示信息框 -->
|
<!-- 显示信息框 -->
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
getDisasterIcon: (disasterType?: string) => string;
|
getDisasterIcon: (disasterType?: string) => string;
|
||||||
prefix: string;
|
prefix: string;
|
||||||
showPoints: boolean;
|
showPoints: boolean;
|
||||||
|
isDefault?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 点处理钩子
|
// 点处理钩子
|
||||||
@@ -25,7 +26,8 @@
|
|||||||
const ids: string[] = pointsHandle.addPoints(
|
const ids: string[] = pointsHandle.addPoints(
|
||||||
props.basePoints,
|
props.basePoints,
|
||||||
props.getDisasterIcon,
|
props.getDisasterIcon,
|
||||||
props.prefix
|
props.prefix,
|
||||||
|
props.isDefault
|
||||||
);
|
);
|
||||||
|
|
||||||
// 显示隐藏点
|
// 显示隐藏点
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
:get-disaster-icon="getDisasterIcon"
|
:get-disaster-icon="getDisasterIcon"
|
||||||
:prefix="config.prefix.riskPointId"
|
:prefix="config.prefix.riskPointId"
|
||||||
:show-points="useStatusStore().getRiskPointShow()"
|
:show-points="useStatusStore().getRiskPointShow()"
|
||||||
|
:is-default="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 显示信息框 -->
|
<!-- 显示信息框 -->
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ export const usePointsHandle = () => {
|
|||||||
* @param points - 点数据数组
|
* @param points - 点数据数组
|
||||||
* @param getDisasterIcon - 获取灾害图标的函数
|
* @param getDisasterIcon - 获取灾害图标的函数
|
||||||
* @param prefix - 前缀
|
* @param prefix - 前缀
|
||||||
|
* @param isDefault - 是否为默认图元,默认false
|
||||||
* @returns 点的ID列表
|
* @returns 点的ID列表
|
||||||
*/
|
*/
|
||||||
function addPoints(
|
function addPoints(
|
||||||
points: Point[],
|
points: Point[],
|
||||||
getDisasterIcon: (disasterType?: string) => string,
|
getDisasterIcon: (disasterType?: string) => string,
|
||||||
prefix: string
|
prefix: string,
|
||||||
|
isDefault: boolean = false
|
||||||
): string[] {
|
): string[] {
|
||||||
// 设置加载配置
|
// 设置加载配置
|
||||||
const options: PrimitiveOptions[] = [];
|
const options: PrimitiveOptions[] = [];
|
||||||
@@ -48,7 +50,7 @@ export const usePointsHandle = () => {
|
|||||||
image: getDisasterIcon(point.disasterType),
|
image: getDisasterIcon(point.disasterType),
|
||||||
scale: 0.8,
|
scale: 0.8,
|
||||||
width: 40,
|
width: 40,
|
||||||
isDefault: false,
|
isDefault: isDefault,
|
||||||
scaleByDistance: new NearFarScalar(500, 1, 5e5, 0.3),
|
scaleByDistance: new NearFarScalar(500, 1, 5e5, 0.3),
|
||||||
customProperties: {
|
customProperties: {
|
||||||
verticalOrigin: VerticalOrigin.BOTTOM,
|
verticalOrigin: VerticalOrigin.BOTTOM,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ export class CesiumUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量添加 Primitive(优化版本)
|
* 批量添加 Primitive
|
||||||
* - 按类型分组后批量创建,减少 scene.primitives.add 调用次数
|
* - 按类型分组后批量创建,减少 scene.primitives.add 调用次数
|
||||||
* - 同类型的多个实例合并到一个 Primitive 或 BillboardCollection 中
|
* - 同类型的多个实例合并到一个 Primitive 或 BillboardCollection 中
|
||||||
* @param primitives - Primitive 配置选项数组
|
* @param primitives - Primitive 配置选项数组
|
||||||
@@ -384,13 +384,12 @@ export class CesiumUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量添加GeoJSON图层
|
* 批量添加GeoJSON图层
|
||||||
* @param layerConfigs - 图层配置数组,每个元素包含 layerId、geojsonData、isDefault 和 options
|
* @param layerConfigs - 图层配置数组,每个元素包含 layerId、geojsonData 和 options
|
||||||
*/
|
*/
|
||||||
async batchAddGeoJsonLayers(
|
async batchAddGeoJsonLayers(
|
||||||
layerConfigs: Array<{
|
layerConfigs: Array<{
|
||||||
layerId: string;
|
layerId: string;
|
||||||
geojsonData: CustomizeGeoJsonDataSource;
|
geojsonData: CustomizeGeoJsonDataSource;
|
||||||
isDefault?: boolean;
|
|
||||||
options?: GeoJsonOptions;
|
options?: GeoJsonOptions;
|
||||||
}>
|
}>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|||||||
@@ -136,7 +136,6 @@ export class EntityManager {
|
|||||||
*/
|
*/
|
||||||
clearAllEntities(clearType: 'default' | 'custom' | 'all' = 'custom'): void {
|
clearAllEntities(clearType: 'default' | 'custom' | 'all' = 'custom'): void {
|
||||||
const targetIds = this.#getTargetIdsByType(clearType);
|
const targetIds = this.#getTargetIdsByType(clearType);
|
||||||
|
|
||||||
targetIds.forEach((id) => {
|
targetIds.forEach((id) => {
|
||||||
const entity = this.#viewer.entities.getById(id);
|
const entity = this.#viewer.entities.getById(id);
|
||||||
if (entity) this.#viewer.entities.remove(entity);
|
if (entity) this.#viewer.entities.remove(entity);
|
||||||
|
|||||||
@@ -103,7 +103,6 @@ export class PrimitiveManager {
|
|||||||
*/
|
*/
|
||||||
clearAllPrimitives(clearType: 'default' | 'custom' | 'all' = 'custom'): void {
|
clearAllPrimitives(clearType: 'default' | 'custom' | 'all' = 'custom'): void {
|
||||||
const targetMap = this.#getTargetMapByType(clearType);
|
const targetMap = this.#getTargetMapByType(clearType);
|
||||||
|
|
||||||
targetMap.forEach((primitive) => {
|
targetMap.forEach((primitive) => {
|
||||||
this.#viewer.scene.primitives.remove(primitive);
|
this.#viewer.scene.primitives.remove(primitive);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user