소스 검색

蜂鸟解析器 解析修改 添加楼层list

haojianlong 5 년 전
부모
커밋
2e56a4ed1f
2개의 변경된 파일19개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      saga-web-fengmap/package.json
  2. 18 1
      saga-web-fengmap/src/parser/SFengParser.ts

+ 1 - 1
saga-web-fengmap/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/feng-map",
-    "version": "1.0.8",
+    "version": "1.0.9",
     "description": "上格云Web平面图。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 18 - 1
saga-web-fengmap/src/parser/SFengParser.ts

@@ -209,6 +209,8 @@ export class SFengParser extends SParser {
         120009,
         120010
     ];
+    /** 当前地图的楼层list */
+    gnameToGid = {};
 
     /** 构造体 */
     constructor(
@@ -235,15 +237,30 @@ export class SFengParser extends SParser {
      * 解析数据
      *
      * @param   currentMapId    当前模型id
-     * @param   groupId         当前楼层
+     * @param   groupId         当前楼层(前台传入为gname)
      * @param   _fn             查询成功回调函数(返回参数为FloorData)
      * */
     parseData(currentMapId: string, groupId: string, _fn: Function): void {
+        // TODO 同一地图不需要重复加载
         this.fmap.openMapById(currentMapId, (err: any) => {
             console.log("错误信息", err);
         });
         this.fmap.on("loadComplete", () => {
+            if (this.currentMapId != currentMapId) {
+                this.currentMapId = currentMapId;
+                this.gnameToGid = {};
+                // @ts-ignore
+                this.fmap.listGroups.forEach(t => {
+                    // @ts-ignore
+                    this.gnameToGid[t.gname] = t.gid;
+                });
+            }
             let obj = {};
+            // @ts-ignore
+            groupId = this.gnameToGid[groupId];
+            if (!groupId) {
+                _fn({ err: "楼层不正确" });
+            }
             // 切换至当前楼层才可查询
             this.fmap.focusGroupID = groupId;
             // 创建搜索分析对象