bill vor 1 Jahr
Ursprung
Commit
cb7b22401d

+ 4 - 1
src/request/type.ts

@@ -138,7 +138,10 @@ export type Device = {
   userName: string;
 };
 
-export type PolygonsPointAttrib = WholeLinePointAttrib & { rtk: boolean };
+export type PolygonsPointAttrib = WholeLinePointAttrib & {
+  rtk: boolean;
+  title: string;
+};
 export type PolygonsLineAttrib = WholeLineLineAttrib;
 
 export type PolygonsAttrib = {

+ 26 - 5
src/view/map/board/index.ts

@@ -1,12 +1,33 @@
 import { Polygons } from "./polygons";
 import { Manage } from "../openlayer";
 import { register, BoundQueryPlugin } from "drawing-board";
-import { PolygonsAttrib } from "@/request/type";
+import { PolygonsAttrib, PolygonsPointAttrib, Scene } from "@/request/type";
+import { SceneStatus } from "@/store/scene";
 
-const initBoard = register(
-  { polygons: Polygons },
-  { bound: new BoundQueryPlugin() }
-);
+const initBoard = register({ polygons: Polygons }, { bound: new BoundQueryPlugin() });
+
+export const scenePosTransform = (scenes: Scene[]) => {
+  const points: PolygonsPointAttrib[] = [];
+
+  scenes.forEach((scene) => {
+    if (scene.calcStatus !== SceneStatus.SUCCESS) {
+      return;
+    }
+    scene.scenePos.forEach((pos) => {
+      if (!pos.pos || pos.pos.length === 0) {
+        return;
+      }
+      points.push({
+        x: pos.pos[0],
+        y: pos.pos[1],
+        title: pos.name,
+        id: pos.id.toString(),
+        rtk: true,
+      });
+    });
+  });
+  return points;
+};
 
 export const createBoard = (container: HTMLDivElement, mapManage: Manage) => {
   const board = initBoard(container, { polygons: undefined }, false);

+ 2 - 1
src/view/map/board/polygons.ts

@@ -23,6 +23,7 @@ import mitt from "mitt";
 const getPolygonPoint = (position: number[]) => {
   const pointAttrib = {
     rtk: false,
+    title: "",
     x: position[0],
     y: position[1],
   };
@@ -86,7 +87,7 @@ const pointActShapeFactory = (attrib: PolygonsPointAttrib, tree: any) => {
     }),
     new Text({
       name: "text",
-      text: `P${attrib.id}`,
+      text: attrib.title || `P${attrib.id}`,
       fontFamily: "Calibri",
       fontSize: 10,
       padding: 5,

+ 26 - 11
src/view/map/map-borad.vue

@@ -36,7 +36,7 @@ import { Manage } from "./openlayer";
 import { ScenePoint, Scene, scenePoints, scenes } from "@/store/scene";
 import { initRelics, initSelfRelics, relics } from "@/store/relics";
 import { onMounted, ref, watchEffect, watch, onUnmounted } from "vue";
-import { createBoard } from "./board/";
+import { createBoard, scenePosTransform } from "./board/";
 import { relicsPolyginsFetch } from "@/request";
 import {
   mapManageInit,
@@ -100,17 +100,32 @@ watch(
         if (mapManage && !autoInitPos()) {
           flyUserCenter(mapManage);
         }
-
-        relicsPolyginsFetch().then((data) => {
-          board.setData(data, router.currentRoute.value.params.relicsId as string);
-          window.board = board;
-          board.polygon().bus.on("clickPoint", (bpoint) => {
-            const point =
-              bpoint.id &&
-              scenePoints.value.find((point) => point.id.toString() === bpoint.id);
-            point && gotoPointPage(point);
-          });
+        const points = scenePosTransform(scenes.value);
+        board.setData(
+          {
+            points,
+            lines: [],
+            polygons: [],
+          },
+          router.currentRoute.value.params.relicsId as string
+        );
+        board.polygon().bus.on("clickPoint", (bpoint) => {
+          const point =
+            bpoint.id &&
+            scenePoints.value.find((point) => point.id.toString() === bpoint.id);
+          point && gotoPointPage(point);
         });
+
+        // relicsPolyginsFetch().then((data) => {
+        //   relics.value;
+        //   board.setData(data, router.currentRoute.value.params.relicsId as string);
+        //   board.polygon().bus.on("clickPoint", (bpoint) => {
+        //     const point =
+        //       bpoint.id &&
+        //       scenePoints.value.find((point) => point.id.toString() === bpoint.id);
+        //     point && gotoPointPage(point);
+        //   });
+        // });
       });
     }
   },

+ 0 - 29
src/view/map/test-board.vue

@@ -1,29 +0,0 @@
-<template>
-  <div class="board-layout" ref="containerRef"></div>
-</template>
-
-<script setup lang="ts">
-import { ref, watch } from "vue";
-import { register, EditWholeLine } from "drawing-board";
-import storeData from "./board/storeData.json";
-
-const containerRef = ref<HTMLDivElement>();
-const initBoard = register({ rooms: EditWholeLine });
-watch(containerRef, (container, _, onClanup) => {
-  if (container) {
-    const board = initBoard(container, storeData, false);
-    console.log(board.tree);
-    onClanup(() => board.destory);
-  }
-});
-</script>
-
-<style lang="scss" scoped>
-.board-layout {
-  position: relative;
-  display: inline-block;
-
-  width: 100vw;
-  height: 100vh;
-}
-</style>