diff --git a/src/apis/map/constant.ts b/src/apis/map/constant.ts index 4819e30..afcdf87 100644 --- a/src/apis/map/constant.ts +++ b/src/apis/map/constant.ts @@ -147,8 +147,8 @@ export const EDITOR_CONFIG: Options = { disableRotate: true, /** 禁用尺寸调整 - 允许图形大小调整 */ disableSize: false, - /** 禁用锚点 - 禁用连接锚点显示 */ - disableAnchor: false, + /** 禁用锚点 - 禁用连接锚点显示,点位不需要锚点,只有区域需要 */ + disableAnchor: true, /** 禁用空线条 - 不允许创建没有连接点的线条 */ disableEmptyLine: true, /** 禁用重复线条 - 不允许在同一对点之间创建多条线 */ diff --git a/src/services/editor.service.ts b/src/services/editor.service.ts index f4da0b3..4174c98 100644 --- a/src/services/editor.service.ts +++ b/src/services/editor.service.ts @@ -70,6 +70,10 @@ export class EditorService extends Meta2d { await this.#loadScenePoints(points, isImport); this.#loadSceneRoutes(routes, isImport); await this.#loadSceneAreas(areas, isImport); + + // 确保加载的点位在路线上方 + this.#ensurePointsOnTop(); + this.store.historyIndex = undefined; this.store.histories = []; // this.scale(scale);与xd 自定义缩放冲突,暂时去掉 @@ -496,6 +500,17 @@ export class EditorService extends Meta2d { } return area; } + + /** + * 确保所有点位在路线上方 + * 将所有点位移到绘制顺序的最上层 + */ + #ensurePointsOnTop(): void { + const points = this.find('point'); + if (points.length > 0) { + this.top(points); + } + } //#endregion /** @@ -967,7 +982,10 @@ export class EditorService extends Meta2d { }; pen.x! -= pen.width! / 2; pen.y! -= pen.height! / 2; - await this.addPen(pen, false, true, true); + const addedPen = await this.addPen(pen, false, true, true); + + // 将点位移到最上层,确保它们始终显示在路线之上 + this.top([addedPen]); } public updatePoint(id: string, info: Partial): void { @@ -1052,9 +1070,19 @@ export class EditorService extends Meta2d { const line = this.connectLine(p1, p2, undefined, undefined, false); id ||= line.id!; this.changePenId(line.id!, id); - const pen: MapPen = { tags: ['route'], route: { type }, lineWidth: 1, locked: LockState.DisableEdit }; + const pen: MapPen = { + tags: ['route'], + route: { type }, + lineWidth: 1, + locked: LockState.DisableEdit, + canvasLayer: CanvasLayer.CanvasMain, + }; this.setValue({ id, ...pen }, { render: false, history: false, doEvent: false }); this.updateLineType(line, type); + + // 将路线移到底层,确保点位能覆盖在路线之上 + this.bottom([line]); + this.active(id); this.render(); }