# 地图AI对话

# 使用

进入唯杰地图云端管理平台 (opens new window),点击每个图上面的AI图标,可与此地图进行AI对话;或者点击打开地图后,点击右下角的AI 对话图标。

image-20250211091239128

点击打开在线体验地址 (opens new window)

image-20250211143145348

点击查看视频教程 https://www.bilibili.com/video/BV1dGNreCEA8/ (opens new window)

用AI自动生成CAD气温曲线图 https://www.bilibili.com/video/BV1JtKjenEhF (opens new window)

# 安装

通过动态引入script的方式引入vjchat (推荐,可页面初始加载时减少加载脚本体积)

// 加载vjchat库
  // @ts-ignore
  if (typeof vjchat !== "object") {
    // 如果没有环境
    await vjmap.addScript([{
        src: "https://vjmap.com/server/_cloud/lib/vjchat.standalone.umd.js"
    }])
  }
  // @ts-ignore
  let aiChat = vjchat.attachMap(map, vjmap, {
      title: "唯杰地图AI对话", // 标题
      context: context, // 替换默认的上下文函数
      theme: {
        mode: "dark"
      },
      silent: false,
      hiddenUI: false,
      resizable: true,
      minimizePosition: "right",
      position: { right: 10, top: 100 },
      size: { width: 420, height: 500 },
      buttonControl: {
        position: "top-left",
        left: -40,
        top: 5
      },
      opacity: 0.8, // 设置透明度
      onClose: () => {
        // 关闭时回调;
      }
  })
  
  // 销毁
  // aiChat.destroy();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

或者通过 npm instal vjchat 引入 vjchat

import { attachMap } from "vjchat"
attachMap(map, vjmap, {
      title: "唯杰地图AI对话", // 标题
      ... // 内容同上
  })
1
2
3
4
5

# 原理

image-20250211145933029

  • 用户输入问题或相关需求
  • 根据用户问题去知识库检索出与问题相关的知识给大模型
  • 大模型根据用户问题和获取的知识库生成相应的代码
  • 前端解析相关代码并执行输出效果展示

# 提问技巧

因为大模型需要根据问题和匹配到的知识库来自动生成代码,所以能不能根据问题自动匹配到相关知识库是能否回答正确的关键前提。(建议打开设置中 知识库搜索结果确认 ,在每次回答前对自动匹配到的知识库进行确认)

可以AI对话工具栏对话中点击导出工程模板 点击下载工程代码 (opens new window) , 在src\chat\sdk.ts 查看全部代码知识库。

image-20250213092136220

提问技巧就是一定要尽量命中文档中的函数说明, 并且同一句话涉及到多个需求时,要用标点符号如逗号来隔开。

下面是一些错误提问正确提问的相关示例说明:

  • [✗] 中间添加一个蓝色标记
  • [✓] 在地图范围中间,加一个蓝色点标记

解释:要在地图中间加一个点标记,涉及到知识库中的两个函数,一个是获取地图范围getMapGeoBounds,一个是增加一个点标记Marker addMarker, 所以提问时要涉及到要地图范围才能获取到中间的点位置,同时这句话有两个需求,同时尽量用逗号分开。

  • [✗] 创建红色的圆
  • [✓] 通过json数据创建新的地图, 创建中心点为[10,10],半径为5,颜色为红色的圆

解释:创建圆有可能是前端通过圆符号创建圆,也可能是后台通过json创建CAD图形对象的圆,所以要明确需求,需求需在文档知识库中能查到。同时绘制的参数如位置信息要明确。

  • [✗] 采集点坐标输入传感器名称和数值,创建Marker点击能查看相关属性。
  • [✓] 1、采集一个点坐标,获取坐标point。 2、弹出输入对话框,输入传感器名称和数值,获取返回值data。 3、在point位置上创建一个Marker, 可拖动,数据内容为data, 弹窗内容为data,以表单形式展示。

解释:如需求比较复杂时,尽量分步骤说明,同时可用相关变量进行说明。

# 教程

image-20250211150518327

# 图形交互与对话模式

图形交互会检索知识库并自动执行大模型生成的代码并对地图进行操作。

对话模式只会与大模型进行对话(不会检索知识库),不会执行代码操作。

# 不立即执行代码

勾选后,代码不会立即执行,需要手动点击执行代码,或点击编辑代码再执行

image-20250211150941350

# 知识库搜索结果确认

根据用户问题去知识库检索出与问题相关的知识给大模型,有时会出现与问题无关的知识库或没有搜索到相关的知识,这时候用户可以选中 知识库搜索结果确认 来手动选择相关知识库。

image-20250211151254424

如输入"增加一个功能按钮,按钮名为放大一级,功能为将地图缩放级别放大一级"时,系统会自动把相关的两个函数知识库选中,这时候用户可以手动再选择相关的进行确认后,再交给大模型处理。

# 知识库搜索结果相关性排序

对知识库相关性进行后排序(建议选中)

# 知识库最大返回条数

对知识库进行相关性排序前从数据库中获取的知识库最大返回条数

# 关联历史对话数据

默认不关联历史对话,也就是上次的输入和输出对下次输入输出没有影响 ,没有上下文数据。如有必要,可进行设置。

# 大模型设置

image-20250211152318677

默认情况下,会调用唯杰地图后端的大模型服务接口,如私有化部署时没有部署唯杰地图后端的大模型服务和想自定义自己申请或已部署的大模型,也可以在前端自定义设置大模型接口地址。

目前支持 ollamaopenAI的接口的大模型。配置示例如下

如设置qwen2.5的openAI模型

image-20250211153239987

使用XAIopenAI模型

image-20250211153400305

使用本地部署的ollama模型

image-20250211153609054

# 粘贴上次用户输入

image-20250211154433208

可用户想在上次输入的基础上,进行修改后再提问,可点击“粘贴上次用户输入”

# 清空会话内容

清空会话中的所有内容。(清空后可在历史记录中查看历史数据)

# 撤销上次操作

image-20250211154825934

可点击撤销上次操作对上次执行的代码结果进行撤销操作(注:有些步骤无法撤销)

# 清空地图除底图外的所有数据

点击后会清空地图上除底图外的所有数据

# 清空地图上绘图数据

点击后会清空地图上绘制图层draw上面的所有数据

# 清空地图上所有点标记

点击后会清空地图上所有点标记Marker

# 导出工程模板

可导出为Vue3的工程模板,方便调试和查看全部SDK代码。 在工程中也可以加入用户业务代码与AI对话。

image-20250211160442919

# 执行代码

可加载历史对话代码或加载上一次代码,可编辑相关代码,点击执行,可以代码中加入 debugger 进行调试

image-20250211160531600

# 用户数据集

用户数据集是指提前在此界面中输入用户的GeoJson数据。当在AI对话框中输入"获取用户数据"时将获取此数据。

比如用户有一组geojson数据,需要将geojson中的点用Marker在图中进行标注。可提前把geojson拷贝到“用户数据集”窗口。

image-20250211161238256

输入"获取用户数据中的所有点类型的数据,在相应位置添加点标记, 弹窗内容为数据的属性值" 进行提问,执行结果为:

image-20250211161526454

# 常见提问词

image-20250211161759092

点击常见提问词,可点击某项的“对话”进行直接对话

image-20250211162029067

# 地图图像资源管理

在创建符号symbol时,需要用到图像资源。需提前在地图图像资源管理中对图像进行定义。

默认的图像名称有_markerIcon__scatterDot__pulsingDot_

如自定义图像,可选择本地图像或输入svg内容进行自定义。

image-20250211162716181

如提前上传一个girl.png的图片名称改为girl, 输入问题 “在地图的绘制范围内随机生成5个点, 根据这些位置分别绘制点符号,符号图标为girl” 执行绘制结果如下

image-20250211162932763

# 查看知识库

点击搜索知识库,点击要搜索的相关内容 ,在搜索结果中点击查看

image-20250211163240464

image-20250211163305440

image-20250211163329720

# 历史会话记录

image-20250211163436361

# 接口定义

attachMap函数相关参数定义

export type ThemeMode = 'light' | 'dark'

export interface ThemeConfig {
  mode?: ThemeMode
  primaryColor?: string
  borderColor?: string
  backgroundColor?: string
  containerBackground?: string
  textColor?: string
  codeBgColor?: string
}

export interface BaseChatOptions {
  type?: ModelType
  temperature?: number
  streamCallback?: (content: string) => void
  interactiveSystemPrompt?: string  // 添加图形交互提示词
  chatSystemPrompt?: string 
  rankPrompt?: string;
  historyChatNum?: number
  topK?: number        // 添加对话提示词
  scoreThreshold?: number
  diableAutoExecCode?: boolean
  knowledgeConfirm?: boolean
  knowledgeRank?: boolean
  rankScoreThreshold?: number
  similarityScoreTopK?: number
  welcomePrompt?: string
}

export interface OllamaChatOptions extends BaseChatOptions {
  type: 'ollama'
  model: string
  baseUrl: string
}

export interface OpenAIChatOptions extends BaseChatOptions {
  type: 'openai'
  model: string
  apiKey: string
  baseUrl?: string
}

export type ChatOptions = OllamaChatOptions | OpenAIChatOptions
export interface ChatMapOptions {
  theme?: ThemeConfig;
  chat: ChatOptions;
  resizable?: boolean;
  silent?: boolean;
  hiddenUI?: boolean;
  userVectorDocs?: string;
  size?: {
    width: number;
    height: number;
  };
  position?: {
    left?: number;
    top?: number;
    right?: number;
    bottom?: number;
  };
  opacity?: number;
  minimizePosition?: 'left' | 'right';
  title?: string;
  historyChatNum?: number;
  topK?: number;
  scoreThreshold?: number;
  onClose?: () => void;
}

const defaultThemes: Record<ThemeMode, ThemeConfig> = {
  light: {
    primaryColor: '#409eff',
    borderColor: '#c0c4cc',
    backgroundColor: '#f5f7fa',
    containerBackground: '#ffffff',
    textColor: '#303133',
    codeBgColor: '#f6f8fa'
  },
  dark: {
    primaryColor: '#507F80',
    borderColor: '#666668',
    backgroundColor: '#2d2d2d',
    containerBackground: '#1e1e1e',
    textColor: '#e5eaf3',
    codeBgColor: '#282c34'
  }
}

// 默认配置
const defaultOptions: Partial<ChatMapOptions> = {
  size: {
    width: 600,
    height: 500
  },
  opacity: 0.8,
  minimizePosition: 'right'
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

# 知识库SDK文档

import vjmap, { Map }  from "vjmap";
import vjcommon from "vjcommon";
export class VjChatSDK {
    map: Map;
    context: Record<string, any>;
    constructor(map: Map, context: Record<string, any>) {
        this.map = map;
		this.context = context;
    }

        /**
     * 手动指定公共对应点获取四参数
     * @param {Object} [leftMapOptions] 左边地图的参数,可为空,默认当前地图
     * @param {string} [leftMapOptions.mapid] 地图ID
     * @param {string} [leftMapOptions.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {Object} [rightMapOptions] 右边地图的参数,可为空,高德地图
     * @param {string} [rightMapOptions.mapid] 地图ID
     * @param {string} [rightMapOptions.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {number} [leftMapOptions.webmaptype] 地图类型:1: 高德地图、2: 高德地图影像、3: 天地图、4: 天地图影像
     * @returns {Promise<Object>} 返回参数,返回内容如下
     * @example
      * // 示例一
      * // 手动指定公共对应点获取当前地图和互联网高德地图的四参数
      * let fp = await this.getFourParamter();
      * if (fp) {
      * console.log("四参数", fp.fourParamter);
      * }
      * // 示例二
      * // 手动指定公共对应点获取当前地图和cad地图sys_world的四参数
      * let fp2 = await this.getFourParamter({}, {
      * mapid: "sys_world"
      * });
      * if (fp2) {
      * console.log("四参数", fp2.fourParamter);
      * }
     */
    async getFourParamter(leftMapOptions, rightMapOptions)  {
            return await this.context.ui.getFourParamter(leftMapOptions, rightMapOptions);
          }
    

    /**
     * 增加一个信息窗口Popup
     * @param {[number, number]} pt 要设置的坐标[x, y]
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {any} options.content 弹窗内容,参数可选,默认为空表示不显示弹窗
     * @param {[number, number]} options.offset 弹窗偏移量,参数可选,默认为[0, -40]
     * @param {boolean} options.showInForm 弹窗内容是否以表单形式显示,参数可 选,默认为false
     * @param {boolean} options.isOpen 弹窗内容是否打开,参数可选,默认为false
     * @param {string} options.anchor 锚点, 选项包括'center','top','bottom','left','right','top-left','top-right','bottom-left',和'bottom-right'。参数可选
     * @param {string} options.maxWidth 弹窗最大宽度,参数可选,默认为'auto'
     * @param {string} options.width 弹窗宽度,参数可选
     * @param {string} options.height 弹窗高度,参数可选
     * @param {string} options.className 弹窗样式类名,参数可选,默认为空
     * @param {boolean} options.closeButton 是否显示关闭按钮,参数可选,默认为true
     * @param {boolean} options.closeOnClick 是否点击弹窗外部关闭弹窗,参数可选,默认为false
     * @param {boolean} options.closeOnMove 是否地图移动时关闭弹窗,参数可选,默认为false
     * @param {boolean} options.focusAfterOpen 是否打开弹窗后聚焦弹窗,参数可选,默认为true
     * @param {number} options.elevation 坐标标高值,参数可选,默认为0
     * @param {boolean} options.visible 是否显示,参数可选,默认为true
     * @param {any} options.data 数据内容,参数可选,默认为空
     * @returns {string} 返回id
     * @example
      * // 在坐标[30,50]处添加一个信息窗口,内容为"Hello,World"
      * let popupId = this.addPopup([30, 50], {
      * content: "Hello,World"
      * });
      * console.log(popupId);
     */
    addPopup(pt, options)  {
            options = options || {};
            let popup = new vjmap.Popup({
                offset: options.offset, 
                anchor: options.anchor,
                maxWidth: options.maxWidth,
                className: options.className,
                closeButton: options.closeButton === undefined ? true : options.closeButton,
                closeOnClick: options.closeOnClick,
                closeOnMove: options.closeOnMove,
                focusAfterOpen: options.focusAfterOpen
            })
            const dom = this.context.ui.createElementByJsonData(options.content, options.showInForm, {
                width: options.width,
                height: options.height
            })
            popup.setDOMContent(dom.element)
          
            popup.id = "popup_" + vjmap.RandomID()
            if (options.data) popup.data = options.data;
            if (pt) {
                popup.setLngLat(this.map.toLngLat(pt));
            }
            if (options.visible !== false || options.isOpen) {
                popup.addTo(this.map);
            }
    
            if (options.elevation) {
                popup.setHeight(options.elevation);
            }
    
            this.context.global.popups = this.context.global.popups || [];
            this.context.global.popups.push({id: popup.id, popup: popup, options: options});
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deletePopup(popup.id);
            });
            return popup.id
        }
    

    /**
     * 目标匹配
     * @param {object} options 参数
     * @param {string} [options.mapid] 地图ID
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {number} [options.selectWay] 选择方式. 0表示框选实体,1表示点选实体, 2不手动选择实体,默认0
     * @param {string} [options.layer] 图层样式名 为空时,将由选择的实体的图层来决定
     * @param {string} [options.mapBounds] 目标匹配的地图范围,默认为全图的数据范围
     * @param {string} [options.objectIds] 目标匹配的实体objectid数组,用||隔开
     * @param {string} [options.objectBounds] 目标匹配的实体范围
     * @param {string} [options.layeron] 目标匹配的地图打开的图层
     * @param {number} [options.size] 匹配时的图像尺寸,默认10000
     * @param {string} [options.method] 方法. 默认 matchPattern
     * @param {number} [options.maxCount] 允许返回的最大条数. 默认 200
     * @param {number} [options.score] 分数,小于此分类将不显示 (0 -1),默认 0.6
     * @param {number} [options.minReduceArea] 金字塔大小 范围(64-2048).默认256, 方法为matchPattern有效
     * @param {boolean} [options.canOverlap] 允许重叠 (默认false)
     * @param {number} [options.maxOverlap] 重叠比例 范围(0-0.8),默认 0.3
     * @param {number} [options.toleranceAngle] 角度范围(-180, 180)有旋转的时候需要。方法为matchPattern有效. 默认180
     * @param {boolean} [options.useToleranceRange] 是否使用角度区间范围,默认false. 方法为matchPattern有效
     * @param {number} [options.tolerance1] 角度区间1开始角度. 方法为matchPattern有效
     * @param {number} [options.tolerance2] 角度区间1结束角度. 方法为matchPattern有效
     * @param {number} [options.tolerance3] 角度区间2开始角度. 方法为matchPattern有效
     * @param {number} [options.tolerance4] 角度区间2结束角度. 方法为matchPattern有效
     * @param {boolean} [options.showSettingForm] 是否弹出设置对话框. 默认true
     * @returns {Promise<GeoJSON>} 返回比较结果, 如果失败则返回undefined, 如果成功则返回匹配的GeoJSON数据
     * @example
      * // 点选实体对当前地图进行目标匹配
      * let res = await this.matchObject({
      * selectWay: 1
      * });
      * console.log(res);
     */
    async matchObject(options)  {
           options = options || {};
           let svc = this.map.getService();
           options = {
            mapid: options.mapid || svc.currentMapParam().mapid,
            objectIds: '',
            objectBounds: '',
            method: "matchPattern",
            maxCount: 200,
            score: 0.6,
            size: 10000,
            canOverlap: false,
            maxOverlap: 0.3,
            toleranceAngle: 180,
            layer: "",
            layeron: "",
            ...options,
           }
           if (options.selectWay === 0) {
             let isPointSel = options.selectWay === 1;
             let param = {};
             let res = await vjcommon.selectFeatures(this.map, true, isPointSel, isPointSel, true);
             vjcommon.clearHighlight(this.map);
             if (!res || res.length == 0) return;
             const objectIds = res.map(f => f.properties.objectid);
             const layeron = `(${Array.from(new Set(res.map(f => f.properties.layerindex))).join(",")})`;
             const features = {
                type: "FeatureCollection",
                features: res
             }
             let data = this.map.fromLngLat(features);
             let bounds = vjcommon.getGeoJsonBounds(data).scale(1.01); // 稍放大点
             param.objectIds = objectIds.join("||");
             param.objectBounds = `[${bounds.toString()}]`;
             param.layeron = layeron;
             options = {
                ...options,
                ...param
             }
           }
           if (options.showSettingForm !== false) {
            options = await this.showDataModifyDlg({
                data: options,
                title: "目标匹配设置",
                showForm: true
            })
            if (!options) return;
           }
           
           let result = await svc.cmdMatchObject(options);
           if (result && result.error) {
                if (this.map.logInfo) this.map.logInfo(result.error, "error", 10000);
                return;
            }
           if (!result || !result.match) return;
           let match = result.match.split(";");
           let geojson = {
            type: "FeatureCollection",
            features: []
           };
            for(let i = 0; i < match.length; i++) {
                if (match[i].indexOf(",") <= 0) continue;
                const items = match[i].split(",");
                const pts = [[+items[0], +items[1]], [+items[2], +items[3]], [+items[4], +items[5]], [+items[6], +items[7]]];
                pts.push(pts[0])
    
                geojson.features.push({
                    type: "Feature",
                    geometry: {
                        type: "LineString",
                        coordinates: pts
                    }
                })
            }
            return geojson;
       }
    

    /**
     * 弹出消息确认框
     * @param {string} message 对话框内容,参数可选
     * @param {string} title 对话框标题,参数可选
     * @param {string} type 对话框类型,可选值为"warning"、"error"、"info"、"success",参数可选
     * @returns {boolean} 返回用户点击的按钮, 点击"确定"返回true,点击"取消"返回false
     * @example
      * // 弹出消息确认框, 消息为"是否删除"
      * let res = await this.messageBoxConfirm("是否删除", "提示", "warning");
      * if (res) {
      * console.log("点击了确定")
      * } else {
      * console.log("点击了取消")
      * }
     */
    async messageBoxConfirm(message, title, type)  {
            return await this.context.ui.confirm(message || "是否确认?", title || "提示", type || "warning");
        }
    

    /**
     * 移除地图导航条控件
     * @example
      * // 移除地图导航条控件
      * this.removeMapNavigationControl();
     */
    removeMapNavigationControl()  {
            this.context.global.controls = this.context.global.controls || {};
            let options;
            if (this.context.global.controls.navigationControl) {
                options = {...this.context.global.controls.navigationControl.options}
                this.map.removeControl(this.context.global.controls.navigationControl.control);
                delete this.context.global.controls.navigationControl;
            }
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                if (options) {
                    this.addMapNavigationControl(options);
                }
            }); 
        }
    
    

    /**
     * 将地图经纬度坐标转换为CAD图几何坐标
     * @returns {[number, number]} 返回包含两个数字的数组[x,y],表示CAD图几何坐标
     * @example
      * // 将地图经纬度坐标[10, 20]转换为CAD图几何坐标
      * let point = this.lngLatToGeoPoint([10, 20]);
      * let x = point[0];
      * let y = point[1];
      * console.log(x, y);
     */
    lngLatToGeoPoint(lngLat)  {
            let geoPoint = this.map.fromLngLat(lngLat);
            return [geoPoint.x, geoPoint.y];
        }
    

    /**
     * 保存用户自定义数据至服务端
     * @param {any} value 键值
     * @param {any} prop 属性值
     * @param {number} ttl 有效时间,单位秒,默认长期有效
     * @returns {Promise<boolean>} 返回保存是否成功, true表示成功,false表示失败
     * @example
      * // 保存用户自定义数据至服务端,键名为testKey,值为testValue,属性为{ prop1: "value1" }
      * await this.saveCustomDataServer("testKey", "testValue", { prop1: "value1" });
      * // 批量保存用户自定义数据至服务端,键名为testKey1,值为testValue1,属性为{ prop1: "value1" },有效时间为3600秒,键名为testKey2,值为testValue2,属性为{ prop2: "value2" },有效时间为7200秒
      * await this.saveCustomDataServer([
      * { key: "testKey1", value: "testValue1", prop: { prop1: "value1" }, ttl: 3600 },
      * { key: "testKey2", value: "testValue2", prop: { prop2: "value2" }, ttl: 7200 }
      * ]);
     */
    async saveCustomDataServer(key, value, prop, ttl)  {
            let svc = this.map.getService();
            let res = await svc.saveCustomData(key, value, prop, ttl);
            return res?.status === "ok";
        }
    

    /**
     * 设置数据图层是否可见
     * @param {string} layerName 图层名称,参数必填
     * @param {boolean} visible 是否可见,参数必填
     * @example
      * // 设置图层名称为layer1的数据图层隐藏
      * let layerName = 'layer1';
      * this.setDataLayerVisible(layerName, false);
     */
    setDataLayerVisible(layerName, visible)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item && item.visible != visible) {
                item.visible = visible;
                let layerId = item.layerId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                }
                item.layer.setVisible(this.map, layerId, !visible);
    
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.setDataLayerVisible(item.layerName, visible);
                });
            }
        }
    

    /**
     * 获取cad图epsg代号
     * @param {object} options 配置选项
     * @param {string} [options.mapid] 地图ID,为空的话,采用当前打开的地图
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {"beijing54"|"xian80"|"cgs2000"} [options.crs] cad图的坐标系,beijing54(北京54坐标)、xian80(西安80坐标、cgs2000(CGCS2000坐标)
     * @returns {Promise<string|undefined>} 返回cad图的epsg代号, 如果获取不到,则返回undefined
     * @example
      * //示例一
      * // 获取当前图的epsg代号, 把结果输出至会话窗口
      * let epsg = await this.getCadEpsgCode();
      * if (epsg) {
      * this.chatLog(epsg);
      * } else {
      * this.chatLog("获取cad图的epsg代号失败");
      * }
      * //示例二
      * // 获取图ca422a931980的epsg代号,cad图的坐标系为西安80
      * let epsg2 = await this.getCadEpsgCode({
      * mapid: "ca422a931980",
      * crs: "xian80"
      * });
      * console.log(epsg2);
     */
    async getCadEpsgCode(options)  {
            options = options || {}
            let svc = this.map.getService();
            // 获取中心点,要叠加互联网地图要求是地理坐标X是8位,Y是7位,如果X没有带系的话,X可以是6位
            let center = this.map.fromLngLat(this.map.getCenter());
            if (options.mapid) {
                let metadata = await svc.metadata(options.mapid, options.version);
                let mapExtent = vjmap.GeoBounds.fromString(metadata.bounds);
                center = mapExtent.center();
            }
            let strX = parseInt(center.x) + "";
            let xLen = strX.length;
            let yLen = (parseInt(center.y) + "").length;
            if (yLen == 7) {
                let crs = vjmap.transform.EpsgCrsTypes.CGCS2000;
                if (options.crs == "beijing54") {
                    crs = vjmap.transform.EpsgCrsTypes.Beijing54;
                } else if (options.crs == "xian80") {
                    crs = vjmap.transform.EpsgCrsTypes.Xian80;
                }
                if (xLen == 8) {
                    let epsg = vjmap.transform.getEpsgParam(crs, +strX.substring(0, 2))?.epsg;
                    if (epsg) {
                        return epsg;
                    }
                } else if (xLen == 6) {
                    // 如果是6位的坐,前面没有带号信息,需要在互联网地图上选择地图所有的大概位置的经纬度来确定
                    let lngLat = await this.context.ui.selectWebMapLngLat({
                        isGaode: true,
                        isRoadway: true
                    })
                    if (lngLat) {
                        let res = vjmap.transform.getEpsgCode([lngLat.lng, lngLat.lat]);
                        let curEpsg;
                        let curDist;
                        // 获取最接近的epsg
                        for(let item of res) {
                           if (crs == vjmap.transform.EpsgCrsTypes.CGCS2000 && item.crs.indexOf('2000') == -1) {
                              continue;
                            } else if (crs == vjmap.transform.EpsgCrsTypes.Beijing54 && item.crs.indexOf('54') == -1) {
                              continue;
                           } else if (crs == vjmap.transform.EpsgCrsTypes.Xian80 && item.crs.indexOf('80') == -1) {
                              continue;
                           }
                           let epsg = item.epsg;
                           let result = await svc.cmdTransform("EPSG:4326", epsg, vjmap.geoPoint([lngLat.lng, lngLat.lat])); // 如果不想调服务转,也可以在前端用proj4库
                           let pt = result[0];// 返回的第1条结果
                           let dist = vjmap.geoPoint(pt).distanceTo(vjmap.geoPoint(center))
                           if (curDist === undefined) {
                            curDist = dist;
                            curEpsg = epsg;
                           } else if (dist < curDist) {
                            curDist = dist;
                            curEpsg = epsg;
                           }
                        }
                        if (curEpsg) {
                            return curEpsg;
                        }
                    }
                }
            }
            return undefined;
        }
    

    /**
     * 根据给定的坐标位置直接绘制一个矩形
     * @param {[number, number, number, number]} points 矩形的坐标[x1,y1,x2,y2],表示左下角和右上角坐标,参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Object} 返回绘制的图元对象,返回的对象包含以下属性:
     * @example
      * // 创建三个地图范围内随机位置的矩形, 矩形宽高为地图宽度的1/20,颜色随机,填充,透明度0.5, 其中第二个不填充
      * let points = this.randomPointInMapBounds(3);
      * let rect = this.getMapGeoBounds(); // 获取地图范围
      * let width = (rect[2] - rect[0]) / 20; // 矩形宽度为地图宽度的1/20
      * for(let i = 0; i < points.length; i++) {
      * const rect = this.createRectangle([
      * points[i][0], points[i][1],
      * points[i][0] + width, points[i][1] + width
      * ], {
      * color: vjmap.randomColor(),
      * isFill: i == 1 ? false : true,
      * opacity: 0.5,
      * data: i
      * });
      * console.log(`矩形${i+1} ID:`, rect.id);
      * console.log(`矩形${i+1} 坐标:`, rect.points);
      * }
     */
    createRectangle(points, options)  {
            let bounds = vjmap.GeoBounds.fromArray(points);
            let pts = bounds.toPointArray();
            pts.push(pts[0]);
            let draw = this.map.getDrawLayer();
            let id = vjmap.RandomID(10);
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: options.isFill ? 'Polygon' : 'LineString',
                    coordinates: options.isFill ? [pts.map(pt => this.map.toLngLat(pt))] : pts.map(pt => this.map.toLngLat(pt))
                },
                properties: {
                    color: options.color,
                    opacity: options.opacity,
                    data: options.data
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                points
            };
        }
    

    /**
     * 移除鼠标位置控件
     * @example
      * // 移除鼠标位置控件
      * this.removeMousePositionControl();
     */
    removeMousePositionControl()  {
            this.context.global.controls = this.context.global.controls || {};
            let options;
            if (this.context.global.controls.mousePositionControl) {
                options = {...this.context.global.controls.mousePositionControl.options}
                this.map.removeControl(this.context.global.controls.mousePositionControl.control);
                delete this.context.global.controls.mousePositionControl;
            }
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                if (options) {
                    this.addMousePositionControl(options);
                }
            }); 
        }
    
    

    /**
     * 获取所有信息窗口Popup
     * @param {string} id 信息窗口Popup的id
     * @param {[number, number]} position 信息窗口Popup的坐标[x, y]
     * @param {string} data 信息窗口Popup的数据
     * @returns {Array<Object>} 返回所有信息窗口Popup, 每个Popup对象包含:
     * @example
      * // 获取所有信息窗口Popup
      * let popups = this.getAllPopups();
      * for(let i = 0; i < popups.length; i++) {
      * let popup = popups[i];
      * let x = popup.position[0];
      * let y = popup.position[1];
      * console.log(popup.id, x, y, popup.data);
      * }
     */
    getAllPopups()  {
            let popups = this.context.global.popups || [];
            popups = popups.filter(m => m.id !== undefined);
            return popups.map(m => {
                let popup = m.popup;
                let point = this.map.fromLngLat(popup.getLngLat());
                return {
                    id: m.id,
                    position: [point.x, point.y],
                    data: popup.data
                }
            });
         }
    

    /**
     * 创建临时地图, 根据fileid创建一个临时的地图
     * @param {string} fileid 文件id
     * @param {object} options 其他参数(可选), 支持以下参数:
     * @param {boolean} [options.GeomRender] 是否以矢几何渲染打开,, false 内存直接打开,true 几何渲染打开, 默认false
     * @param {number} [options.expireTime] 临时图形不浏览情况下过期自动删除时间,单位分钟。默认5
     * @param {boolean} [options.isVisible] 是否可见,(可见的话,将可通过ListMaps获取,否则为隐藏图)。默认不可见
     * @param {boolean} options.lightTheme 是否使用浅色主题 可选,为空时则使用深色主题
     * @returns {string} 返回创建的图的图id
     * @example
      * //  根据文件id值"c0febd8e49c7"创建一个临时地图
      * let mapid = await this.createTempMap("c0febd8e49c7");
      * console.log(mapid);
     */
    async createTempMap(fileid, options)  {
            options = options || {};
            let svc = this.map.getService().clone();
            let mapid = vjmap.getTempMapId(options.expireTime || 5, options.isVisible);
            // js代码
            let res = await svc.updateMap({
                mapid: mapid,
                fileid: fileid,
                mapopenway: options.GeomRender === true ? vjmap.MapOpenWay.GeomRender : vjmap.MapOpenWay.Memory,
                style:  options.lightTheme ? vjmap.openMapLightStyle() : vjmap.openMapDarkStyle(),
            })
            return res.mapid;
        }
    

    /**
     * 设置地图深色、浅色或高科技主题
     * @param {string} theme 主题,可选值:"dark", "light", "high-tech"
     * @example
      * // 示例一
      * // 设置地图深色主题
      * await this.setMapTheme("dark");
      * // 示例二
      * // 设置地图浅色主题
      * await this.setMapTheme("light");
      * // 示例三
      * // 设置地图高科技主题
      * await this.setMapTheme("high-tech");
     */
    async setMapTheme(theme)  {
            if (!this.context.global.updateMapStyleObj) {
                this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
            }
            const updateMapStyleObj = this.context.global.updateMapStyleObj;
            let style = {
                backcolor: theme === "light" ? 0xffffff : 0,
            };
            if (theme === "high-tech") {
                style.expression = "var color := gFilterCustomTheme(gInColorRed, gInColorGreen, gInColorBlue, 200, 200, 0.1);gOutColorRed[0] := gRed(color);gOutColorGreen[0] := gGreen(color);gOutColorBlue[0] := gBlue(color);";
            }
            const curStyle = {...updateMapStyleObj.getCurStyle()};
            await updateMapStyleObj.updateStyle(style)
            // 添加撤销记录
            this.context.ui.addUndoRecord(async () => {
                await updateMapStyleObj.updateStyle(curStyle)
            });
        }
    

    /**
     * 采集一个多边形的坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<number[][] | undefined>} 返回坐标点数组[[x1,y1],[x2,y2],...],如果取消操作则返回undefined
     * @example
      * const polygon = await this.actionDrawPolygon();
      * if (!polygon) return;
      * // 输出多边形的所有点坐标
      * for (let i = 0; i < polygon.length; i++) {
      * let x = polygon[i][0];
      * let y = polygon[i][1];
      * console.log(x, y);
      * }
     */
    async actionDrawPolygon(isSnap)  {
            this.context.tools.logInfo("请在地图上绘制一个多边形")
            let snapObj = {};
            if (isSnap) {
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawPolygon = await vjmap.Draw.actionDrawPolygon(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawPolygon.cancel) {
                return;
            }
            let coords = drawPolygon.features[0].geometry.coordinates[0];
            return coords.map(c => {
                let p = this.map.fromLngLat(c);
                return [p.x, p.y];
            });
        }
    

    /**
     * 弹出消息输入框
     * @param {string} message 对话框内容,参数可选
     * @param {string} title 对话框标题,参数可选
     * @param {string} inputValue 初始值,参数可选
     * @param {boolean} isPassword 是否为密码输入框,参数可选,默认false
     * @returns {string|undefined} 返回输入的内容, 如果用户点击取消,则返回undefined
     * @example
      * // 弹出消息输入框, 消息为"请输入内容", 初始值为空
      * let res = await this.messageBoxPrompt("请输入内容", "提示", "");
      * if (res !== undefined) {
      * console.log("输入的内容为:", res)
      * } else {
      * console.log("点击了取消")
      * }
     */
    async messageBoxPrompt(message, title, inputValue, isPassword)  {
            return await this.context.ui.prompt(message || "请输入内容", title || "提示", inputValue || "", isPassword || false);
        }
    

    /**
     * 创建动画多边形数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.fillColor 填充颜色
     * @param {string} options.fillOutlineColor 边框颜色
     * @param {number} options.fillOpacity 填充透明度,取值范围0-1
     * @param {string} options.fillPattern 填充图案,必须与地图已加载的图片名称对应,图像宽度必须是2的系数(2、4、8、...、512)
     * @param {[number,number]} options.fillTranslate 几何体的平移量[x,y],负数分别表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillTranslateAnchor 平移参考系,"map"表示相对于地图平移,"viewport"表示相对于视窗平移
     * @param {boolean} options.fillAntialias 是否启用填充反锯齿
     * @param {string} options.animateImagesType 动画类型,可选值:"arrow"(箭头动画), "antpath"(蚂蚁线动画), "customImage"(自定义图片), "imageSprites"(同一个图片精灵动画集)
     * @param {string} options.animateImages_arrowFillColor 箭头填充颜色,当animateImagesType为"arrow"时有效,默认"#22B14C"
     * @param {string} options.animateImages_arrowStrokeColor 箭头边框颜色,当animateImagesType为"arrow"时有效,默认"#fff"
     * @param {number} options.animateImages_arrowStrokeWidth 箭头线宽,当animateImagesType为"arrow"时有效
     * @param {number} options.animateImages_arrowWidth 箭头大小,当animateImagesType为"arrow"时有效
     * @param {string} options.animateImages_fillColor1 蚂蚁线填充颜色1,当animateImagesType为"antpath"时有效
     * @param {string} options.animateImages_fillColor2 蚂蚁线填充颜色2,当animateImagesType为"antpath"时有效
     * @param {string} options.customImageUrl 自定义图片URL或base64,当animateImagesType为"customImage"时有效
     * @param {string} options.imageSpriteUrl 图片动画集URL或base64,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteWidth 来源图片中精灵图所占宽度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteHeight 来源图片中精灵图所占高度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_canvasWidth 画布宽度,所有动画类型通用
     * @param {number} options.animateImages_canvasHeight 画布高度,所有动画类型通用
     * @param {number} options.animateImages_frameCount 动画帧数,所有动画类型通用
     * @param {boolean} options.animateImages_directionReverse 动画方向是否反向,所有动画类型通用
     * @param {number} options.speed 动画速度,步长0.1
     * @param {boolean} options.startAutoAnimation 是否开始时自动播放动画
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer2的动画多边形数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createAnimateFillLayer(geojson, {
      * layerName: 'layer2'
      * });
      * console.log(layer);
     */
    async createAnimateFillLayer(data, options)  {
            options = options || {};
            let type = "animateFill";
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillColor: "#00ffff",
                fillOutlineColor: "#00ff00",
                animateImagesType: "arrow",
                animateImages_arrowFillColor: "#22B14C",
                animateImages_arrowStrokeColor: "#fff",
                animateImages_arrowStrokeWidth: 6,
                animateImages_canvasWidth: 128,
                animateImages_canvasHeight: 32,
                animateImages_arrowWidth: 16,
                animateImages_frameCount: 4,
                animateImages_fillColor1: "#f0fb",
                animateImages_fillColor2: "#0ffb",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createSymbolCircleLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建符号路径动画数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.iconImage 图标名称,用于绘制图像背景的图像名称
     * @param {number} options.iconRotate 图标旋转角度,顺时针旋转,单位为角度,默认0
     * @param {[number,number]} options.iconOffset 图标与锚点偏移距离,[x,y]格式,正值向右和向下
     * @param {string} options.iconAnchor 图标锚定位置,可选值: "center", "left", "right", "top", "bottom", "top-left", "top-right", "bottom-left", "bottom-right"
     * @param {string} options.iconRotationAlignment 图标旋转对齐方式,可选值: "map", "viewport", "auto"
     * @param {string} options.iconPitchAlignment 地图倾斜时图标方向,可选值: "map", "viewport", "auto"
     * @param {boolean} options.iconAllowOverlap 是否允许图标重叠,默认false
     * @param {number} options.iconOpacity 图标透明度,0-1之间,默认1
     * @param {boolean} options.iconIgnorePlacement 是否忽略碰撞检测,默认false
     * @param {boolean} options.iconOptional 图标重叠选项,默认false
     * @param {number} options.iconSize 图标缩放比例,默认1
     * @param {string} options.iconTextFit 图标适应文本方式,可选值: "none", "width", "height", "both"
     * @param {[number,number,number,number]} options.iconTextFitPadding 图标文本匹配padding,[top, right, bottom, left]格式
     * @param {number} options.iconPadding 图标边界填充大小,默认1像素
     * @param {boolean} options.iconKeepUpright 是否防止图标倒置,默认false
     * @param {string} options.iconColor SDF图标颜色,默认"#000000"
     * @param {string} options.iconHaloColor SDF图标光晕颜色,默认"rgba(0, 0, 0, 0)"
     * @param {number} options.iconHaloWidth 图标光晕宽度,默认0
     * @param {number} options.iconHaloBlur 图标光晕模糊度,默认0
     * @param {[number,number]} options.iconTranslate 图标平移距离,[x,y]格式
     * @param {string} options.iconTranslateAnchor 图标平移参考系,可选值: "map", "viewport"
     * @param {string|Expression} options.textField 文本标签内容
     * @param {string[]} options.textFont 文本字体,默认["Open Sans Regular","Arial Unicode MS Regular"]
     * @param {number} options.textSize 文本大小,默认16
     * @param {boolean} options.textAllowOverlap 是否允许文本重叠,默认false
     * @param {string} options.textColor 文本颜色,默认"#000000"
     * @param {number} options.textOpacity 文本透明度,0-1之间,默认1
     * @param {[number,number]} options.textOffset 文本偏移,[x,y]格式
     * @param {number} options.textRotate 文本旋转角度
     * @param {number} options.textPadding 文本内边距,默认2
     * @param {boolean} options.textKeepUpright 是否防止文本倒置,默认true
     * @param {number} options.textMaxWidth 文本最大宽度,默认10em
     * @param {number} options.textLineHeight 文本行高,默认1.2
     * @param {number} options.textLetterSpacing 文字间距,默认0
     * @param {string} options.textJustify 文本对齐方式,可选值: "auto", "left", "center", "right"
     * @param {string} options.textAnchor 文本锚点位置
     * @param {string} options.textRotationAlignment 文本旋转对齐方式
     * @param {string} options.textPitchAlignment 文本倾斜对齐方式
     * @param {number} options.textMaxAngle 相邻字符最大角度,默认45°
     * @param {string[]} options.textWritingMode 文本书写模式
     * @param {string} options.textTransform 文本转换方式,可选值: "none", "uppercase", "lowercase"
     * @param {number} options.textRadialOffset 文本径向偏移
     * @param {string[]} options.textVariableAnchor 文本可变锚点位置数组
     * @param {boolean} options.textIgnorePlacement 是否忽略文本位置
     * @param {boolean} options.textOptional 文本显示选项
     * @param {string} options.textHaloColor 文本光晕颜色
     * @param {number} options.textHaloWidth 文本光晕宽度
     * @param {number} options.textHaloBlur 文本光晕模糊度
     * @param {[number,number]} options.textTranslate 文本平移距离
     * @param {string} options.textTranslateAnchor 文本平移参考系
     * @param {string} options.symbolPlacement 符号放置位置,可选值: "point", "line", "line-center"
     * @param {number} options.symbolSpacing 符号间距,默认250
     * @param {boolean} options.symbolAvoidEdges 是否避免边缘碰撞
     * @param {string} options.symbolZOrder 符号绘制顺序,可选值: "auto", "viewport-y", "source"
     * @param {string} options.lineColor 线条颜色,参数可选,默认为'#ff0000'
     * @param {number} options.lineWidth 线宽,参数可选,默认为1
     * @param {number} options.lineOpacity 线透明度,参数可选,取值范围0-1
     * @param {number} options.lineGapWidth 线间隙宽度,参数可选,默认为1,单位像素
     * @param {number} options.lineOffset 线的偏移量,参数可选。正值向右/内偏移,负值向左/外偏移
     * @param {number} options.lineBlur 线模糊度,参数可选,需小于线宽度
     * @param {[number,number]} options.lineDasharray 虚线样式,参数可选,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,参数可选,格式如[x,y],负数表示左和上,单位像素
     * @param {string} options.lineCap 线帽形状,参数可选,可选值:'butt'(尖头)、'round'(圆头)、'square'(平头)
     * @param {string} options.lineJoin 拐角形状,参数可选,可选值:'bevel'(平拐)、'round'(圆拐)、'miter'(棱拐)
     * @param {string} options.linePattern 线图案,参数可选,需与预加载的图片名称对应,图像宽度必须是2的幂次
     * @param {string} options.lineGradient 线渐变,参数可选
     * @param {boolean} options.drawPath 是否绘制路径线,可选值: true, false
     * @param {number} options.anmiDuration 动画持续时长,单位为秒,默认5。时长为0表示没有动画
     * @param {number} options.anmiRepeat 动画持续次数,默认0。次数为0表示无限循环
     * @param {string} options.anmiRepeatType 动画重复类型,可选值: "reverse"(来回往返), "loop"(循环), "mirror"(镜像)
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer26的符号路径动画数据图层, 图标名称为_markerIcon_
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createSymbolPathAnimateLayer(geojson, {
      * layerName: 'layer26',
      * iconImage: '_markerIcon_'
      * });
      * console.log(layer);
     */
    async createSymbolPathAnimateLayer(data, options)  {
            options = options || {};
            let type = "symbolPathAnimate";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                drawPath: true,
                anmiDuration: 5,
                lineColor: '#75E7EF',
                lineOpacity: 0.4,
                lineWidth: 20,
                iconAllowOverlap: true,
                textAllowOverlap: true,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createSymbolPathAnimateLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建栅格瓦片图层
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {number} options.rasterOpacity 图片的不透明度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterHueRotate 在色轮上旋转色相的角度,参数可选,默认值为 0,单位:角度
     * @param {number} options.rasterBrightnessMin 图片的最小亮度,参数可选,取值范围为 0 ~ 1,默认值为 0
     * @param {number} options.rasterBrightnessMax 图片的最大亮度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterSaturation 图片的饱和度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {number} options.rasterContrast 图片的对比度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {number} options.rasterFadeDuration 切换瓦片时的渐隐时间,参数可选,默认值为 300,单位:毫秒
     * @param {string} options.rasterResampling 采样方式,参数可选,可选值为 linear、nearest,默认值为 linear
     * @param {string} options.tileMapId 瓦片的mapid,参数可选
     * @param {string} options.tileMapVersion 瓦片的版本,参数可选
     * @param {string} options.tileMapLayer 瓦片的样式图层名称,参数可选
     * @param {string|Array<string>} options.tiles 瓦片地址,支持变量 {x},{y},{z},{serviceUrl},{accessToken}
     * @param {number} options.tileSize 瓦片大小,参数可选,默认值为 512
     * @param {number[]} options.bounds 瓦片范围,参数可选,格式为[minx, miny, maxx, maxy],默认为全图范围
     * @param {string} options.scheme 瓦片y方向,参数可选,可选值为 xyz(Y从顶部开始)、tms(Y从底部开始),默认为 xyz
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 创建栅格瓦片图层, 瓦片的mapid为sys_hello
      * let layer = await this.createRasterLayer({
      * tileMapId: "sys_hello",
      * });
      * console.log(layer);
     */
    async createRasterLayer(options)  {
            options = options || {};
            let type = "raster";
    
            let randomId = vjmap.RandomID();
            let sourceId = `source_${type}_${randomId}`;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                sourceId,
                layerId,
                ...options,
                type: type
            }
    
            if (options.tileMapId && !options.tiles) {
                let layer = options.tileMapLayer;
                if (!layer) {
                    let style = await this.map.getService().createStyle({
                        backcolor: this.map.getService().currentMapParam().darkMode ? 0x000000 : 0xFFFFFF
                    }, options.tileMapId, options.tileMapVersion);
                    layer = style.stylename
                }
                let tileUrl = this.map.getService().rasterTileUrl({
                    mapid: options.tileMapId,
                    version: options.tileMapVersion,
                    layer: layer,
                })
                options.tiles = tileUrl;
            }
            if (options.bounds) {
                const p1 = this.map.toLngLat([options.bounds[0], options.bounds[1]]);
                const p2 = this.map.toLngLat([options.bounds[2], options.bounds[3]]);
                options.bounds = [p1[0], p1[1], p2[0], p2[1]];
            }
            let sourceData = {
                type: "raster",
                tiles: Array.isArray(options.tiles) ? options.tiles : [options.tiles],
                tileSize: options.tileSize || 256
            }
            if (options.bounds) {
                sourceData.bounds = options.bounds;
            }
            if (options.scheme) {
                sourceData.scheme = options.scheme;
            }
            this.map.addRasterSource(sourceId, sourceData);
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data: sourceData, options, layer, visible: true, create: this.createRasterLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 采集一个矩形坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<number[] | undefined>} 返回包含四个数字的数组[x1,y1,x2,y2],表示矩形的左下角和右上角坐标,如果取消操作则返回undefined
     * @example
      * // 采集一个矩形坐标
      * const rect = await this.actionDrawRectangle();
      * if (!rect) return;
      * // 矩形左下角坐标
      * const leftBottomX = rect[0];
      * const leftBottomY = rect[1];
      * // 矩形右上角坐标
      * const rightTopX = rect[2];
      * const rightTopY = rect[3];
      * console.log(leftBottomX, leftBottomY, rightTopX, rightTopY);
     */
    async actionDrawRectangle(isSnap)  {
            this.context.tools.logInfo("请在地图上绘制一个矩形")
            let snapObj = {};
            if (isSnap) {
                // 捕捉dwg图上的点
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawRect = await vjmap.Draw.actionDrawRectangle(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawRect.cancel) {
                return; // 取消操作
            }
            let co = drawRect.features[0].geometry.coordinates[0];
            co = this.map.fromLngLat(co);
            return [co[0].x, co[0].y, co[2].x, co[1].y];
        }
    

    /**
     * 获取地图范围
     * @param {number} 范围类型(0 地图绘制范围,1 地图实际范围, 2 地图整个范围),默认0, 参数可选
     * @returns {[number, number, number, number]} 返回包含四个数字的数组[x1,y1,x2,y2],表示地图范围的左下角和右上角坐标
     * @example
      * // 获取地图的范围
      * let rect = this.getMapGeoBounds();
      * let minx = rect[0];
      * let miny = rect[1];
      * let maxx = rect[2];
      * let maxy = rect[3];
      * let width = maxx - minx; // 地图范围宽度
      * let height = maxy - miny; // 地图范围高度
      * console.log(minx, miny, maxx, maxy, width, height);
      * // 获取地图实际范围
      * let rect2 = this.getMapGeoBounds(1);
      * console.log(rect2);
     */
    getMapGeoBounds(boundsType)  {
            boundsType = boundsType || 0;
            let geoBounds;
            if (boundsType == 1) {
                // CAD图实际范围(整个地图范围的0.4倍) this.map.getGeoBounds(0.4) // 正方形
                geoBounds = this.map.getGeoBounds(0.4) 
            } else if (boundsType == 2) {
                // 整个地图范围 this.map.getGeoBounds(1.0) // 正方形
                geoBounds = this.map.getGeoBounds(1)
            } else {
                // 地图绘制范围
                geoBounds = this.map.getService().currentMapParam().drawBounds || this.map.getGeoBounds(0.4) 
            }
            return geoBounds.toArray()
        }
    

    /**
     * 设置地图的倾斜角度
     * @param {number} pitch 要设置的倾斜角度
     * @example
      * this.setPitch(60); // 设置倾斜角度为60度
     */
    setPitch(pitch)  {
            let oldPitch = this.map.getPitch(); // 获取当前倾斜角度
            this.map.setPitch(pitch); // 设置新的倾斜角度
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.setPitch(oldPitch);
            });
        }
    

    /**
     * 手动交互式绘制一个圆
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一个圆
      * const circle = await this.drawCircle({
      * isSnap: true,
      * color: "#FF0000",
      * isFill: true,
      * opacity: 0.8
      * });
      * if (!circle) return;
      * console.log("圆ID:", circle.id);
      * console.log("圆心:", circle.center);
      * console.log("半径:", circle.radius);
     */
    async drawCircle(options)  {
            let circle = await this.actionDrawCircle(options.isSnap);
            if (!circle) return;
            return this.createCircle(circle.center, circle.radius, options);
        }
    

    /**
     * 手动交互式绘制一个点
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {number} options.size 点大小,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一个点
      * const pt = await this.drawPoint(); // 启用捕捉功能采绘制一个点坐标
      * if (!pt) return;
      * // 点的坐标
      * let point = pt.point;
      * const x = point[0];
      * const y = point[1];
      * console.log(x, y);
      * // 图元ID
      * let id = pt.id;
      * console.log(id);
      * // 手动绘制一个点,颜色为红色,大小为10,数据值为123,启用捕捉
      * const pt2 = await this.drawPoint({
      * isSnap: true,
      * color: "#FF0000",
      * size: 10,
      * data: 123
      * });
      * console.log(pt2);
     */
    async drawPoint(options)  {
            options = options || {};
            let point = await this.actionDrawPoint(options.isSnap);
            if (!point) return;
            return this.createPoint(point, options);
        }
    

    /**
     * 设置信息窗口Popup的属性
     * @param {string} id 信息窗口Popup的id
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {[number, number]} options.position 坐标[x, y],参数可选,默认为undefined
     * @param {any} options.content 弹窗内容,参数可选,默认为空表示不显示弹窗
     * @param {boolean} options.showInForm 弹窗内容是否以表单形式显示,参数可 选,默认为false
     * @param {number} options.elevation 坐标标高值,参数可选,默认为0
     * @param {boolean} options.visible 是否显示,参数可选,默认为true
     * @param {any} options.data 数据内容,参数可选,默认为空
     * @example
      * // 设置id为popup_1的信息窗口的属性,坐标为[10, 20],弹窗内容为{name: "Sensor", value: 100}, 弹窗内容以表单形式展示
      * this.setPopupProperty("popup_1", {
      * position: [10, 20],
      * content: {name: "Sensor", value: 100},
      * showInForm: true
      * });
     */
    setPopupProperty(id, options)  {
            let popups = this.context.global.popups || [];
            let item = popups.find(m => m.id == id);
            if (!item) return;
            let popup = item.popup;
            let oldOptions = {...item.options, ...options};
            if (options.position) {
                popup.setLngLat(this.map.toLngLat(options.position));
            }
            if (options.data !== undefined) {
                popup.data = options.data;
            }
            if (options.content !== undefined || options.showInForm !== undefined) {
                const dom = this.context.ui.createElementByJsonData(options.content || oldOptions.content, options.showInForm || oldOptions.showInForm)
                popup.setDOMContent(dom.element)
            }
    
            if (options.elevation !== undefined) {
                popup.setHeight(options.elevation);
            }
           
            if (options.data !== undefined) {
                popup.data = options.data;
            }
            if (options.visible !== undefined) {
                if (options.visible) {
                    if (!popup._map) {
                        popup.addTo(this.map);
                    }
                    
                } else {
                    if (popup._map) {
                        popup.remove();
                    }
                }
            }
            
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.setPopupProperty(id, oldOptions);
            });
            
         }
    

    /**
     * 手动交互式绘制一个斜矩形
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一个斜矩形
      * const rect = await this.drawSlantRectangle({
      * isSnap: true,
      * color: "#FF0000",
      * isFill: true,
      * opacity: 0.8
      * });
      * if (!rect) return;
      * console.log("斜矩形ID:", rect.id);
      * console.log("斜矩形的点坐标:", rect.points);
     */
    async drawSlantRectangle(options)  {
            let points = await this.actionDrawSlantRectangle(options.isSnap);
            if (!points) return;
            return this.createPolygon(points, options);
        }
    

    /**
     * 增加地图导航条控件
     * @param {boolean} options.showCompass 是否显示指南针,参数可选
     * @param {boolean} options.showZoom 是否显示缩放按钮,参数可选
     * @param {boolean} options.visualizePitch 是否显示倾斜按钮,参数可选
     * @param {'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} options.position 控件位置,参数可选, 默认'top-right'
     * @example
      * // 增加地图导航条控件,位置左上角
      * this.addMapNavigationControl('top-left');
     */
    addMapNavigationControl(options)  {
            options = options || {};
            this.context.global.controls = this.context.global.controls || {};
            if (this.context.global.controls.navigationControl) {
                this.map.removeControl(this.context.global.controls.navigationControl.control);
            }
            let navigationControl = new vjmap.NavigationControl(options);
            this.map.addControl(navigationControl, options.position);
            this.context.global.controls.navigationControl = {
                control: navigationControl,
                position: options.position,
                options: options
            };
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.removeControl(navigationControl);
                delete this.context.global.controls.navigationControl;
            }); 
        }
    

    /**
     * 设置当前地图栅格底图样式
     * @param {object} options 其他参数,参数可选
     * @param {number} options.rasterOpacity 图片的不透明度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterHueRotate 在色轮上旋转色相的角度,参数可选,默认值为 0,单位:角度
     * @param {number} options.rasterBrightnessMin 图片的最小亮度,参数可选,取值范围为 0 ~ 1,默认值为 0
     * @param {number} options.rasterBrightnessMax 图片的最大亮度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterSaturation 图片的饱和度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {number} options.rasterContrast 图片的对比度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {boolean} options.showSettingForm 是否弹出设置对话框. 默认true
     * @example
      * // 设置当前地图栅格底图样式
      * this.setMapRasterLayerStyle();
     */
    async setMapRasterLayerStyle(options)  {
            options = options || {};
            let showSettingForm = options.showSettingForm === undefined ? true : options.showSettingForm;
            let oldStyle = {...this.map.getLayerStyle(this.map.getService().rasterLayerId())?.paint};
            // 将样式转换为驼峰命名
            let formattedOldStyle = {};
            for (let key in oldStyle) {
                let camelCaseKey = key.replace(/-([a-z])/g, (match, p1) => p1.toUpperCase());
                formattedOldStyle[camelCaseKey] = oldStyle[key];
            }
            oldStyle = formattedOldStyle;
            delete options.showSettingForm;
            options = {
                rasterOpacity: oldStyle.rasterOpacity || 1,
                rasterHueRotate: oldStyle.rasterHueRotate || 0,
                rasterBrightnessMin: oldStyle.rasterBrightnessMin || 0,
                rasterBrightnessMax: oldStyle.rasterBrightnessMax || 1,
                rasterSaturation: oldStyle.rasterSaturation || 0,
                rasterContrast: oldStyle.rasterContrast || 0,
                ...options,
            }
            let svc = this.map.getService();
            let layerId = svc.rasterLayerId();
            const setRasterStyle = (data) => {
                this.map.setRasterOpacity(layerId, data.rasterOpacity || 1);
                this.map.setRasterHueRotate(layerId, data.rasterHueRotate || 0);
                this.map.setRasterBrightnessMin(layerId, data.rasterBrightnessMin || 0);
                this.map.setRasterBrightnessMax(layerId, data.rasterBrightnessMax || 1);
                this.map.setRasterSaturation(layerId, data.rasterSaturation || 0);
                this.map.setRasterContrast(layerId, data.rasterContrast || 0);
            }
            if (showSettingForm) {
                let dataOptions = {
                    rasterOpacity: {
                        type:"slider",
                        field:"rasterOpacity",
                        title:"图片的不透明度",
                        value:options.rasterOpacity,
                        props:{
                            min: 0,
                            max: 1,
                            step: 0.01
                        }
                    },
                    rasterHueRotate: {
                        type:"slider",
                        field:"rasterHueRotate",
                        title:"在色轮上旋转色相的角度",
                        value: options.rasterHueRotate,
                        props:{
                            min: 0,
                            max: 360
                        }
                    },
                    rasterBrightnessMin: {
                        type:"slider",
                        field:"rasterBrightnessMin",
                        title:"图片的最小亮度",
                        value: options.rasterBrightnessMin,
                        props:{
                            min: 0,
                            max: 1,
                            step: 0.01
                        }
                    },
                    rasterBrightnessMax: {
                        type:"slider",
                        field:"rasterBrightnessMax",
                        title:"图片的最大亮度",
                        value: options.rasterBrightnessMax,
                        props:{
                            min: 0,
                            max: 1,
                            step: 0.01
                        }
                    },
                    rasterSaturation: {
                        type:"slider",
                        field:"rasterSaturation",
                        title:"图片的饱和度",
                        value: options.rasterSaturation,
                        props:{
                            min: -1,
                            max: 1,
                            step: 0.01
                        }
                    },
                    rasterContrast: {
                        type:"slider",
                        field:"rasterContrast",
                        title:"图片的对比度",
                        value: options.rasterContrast,
                        props:{
                            min: -1,
                            max: 1,
                            step: 0.01
                        }
                    },
                }
                options = await this.showDataModifyDlg({
                    data: dataOptions,
                    title: "栅格底图样式设置",
                    showForm: true,
                    applyCallback: (data) => {
                        setRasterStyle(data);
                    }
                })
                if (!options) {
                    // 如果用户点击取消,则恢复原来的样式
                    setRasterStyle(oldStyle);
                    return
                }
            }
            setRasterStyle(options);
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                setRasterStyle(oldStyle);
            });
        }
    

    /**
     * 移动图层
     * @param {string} layerName 图层名称,参数必填
     * @param {object} options 其他参数,参数可选
     * @param {string} options.beforeLayerName 移动到此图层之前,参数可选
     * @param {string} options.topMost 移动到最顶层,参数可选
     * @param {string} options.bottomMost 移动到底层,参数可选
     * @example
      * // 示例一
      * // 移动图层名称为layer1的数据图层到最顶层
      * let layerName = 'layer1';
      * this.moveLayer(layerName, {
      * topMost: true
      * });
      * // 示例二
      * // 移动图层名称为layer1的数据图层到最底层
      * this.moveLayer(layerName, {
      * bottomMost: true
      * });
      * // 示例三
      * // 移动图层名称为layer1的数据图层到图层名称为layer2的数据图层之前
      * this.moveLayer(layerName, {
      * beforeLayerName: 'layer2'
      * });
     */
    moveLayer(layerName, options)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item) {
                item.visible = true;
                let layerId = item.layerId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                }
                let layers = this.map.getStyle().layers;
                let oldBeforeLayerId;
                let index = layers.findIndex(item => item.id == layerId);
                if (index < layers.length - 1) {
                    oldBeforeLayerId = layers[index + 1].id;
                }
                
                if (options.topMost) {
                    this.map.moveLayer(layerId);
                } else if (options.bottomMost) {
                    this.map.moveLayer(layerId, layers[0].id);
                } else if (options.beforeLayerName) {
                    let itemBefore = this.context.global.layers.find(layer => layer.layerName == options.beforeLayerName);
                    let beforeLayerId;
                    if (itemBefore) {
                        beforeLayerId = itemBefore.layerId;
                        if (itemBefore.layer && typeof(itemBefore.layer.getLayerId) == "function") {
                            beforeLayerId = itemBefore.layer.getLayerId();
                        }
                    }
                    this.map.moveLayer(beforeLayerId);
                }
    
    
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    if (oldBeforeLayerId) {
                        this.map.moveLayer(layerId, oldBeforeLayerId);
                    }
                });
            }
        }
    

    /**
     * 手动交互式绘制一条线
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {number} options.width 线宽,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一条线
      * const line = await this.drawLineString({
      * isSnap: true,
      * color: "#FF0000",
      * width: 2
      * });
      * if (!line) return;
      * console.log("线ID:", line.id);
      * console.log("线的点坐标:", line.points);
     */
    async drawLineString(options)  {
            let points = await this.actionDrawLineString(options.isSnap);
            if (!points) return;
            return this.createLineString(points, options);
        }
    

    /**
     * 弹出数据创建修改对话框
     * @param {object} options 数据面板配置,可选
     * @param {any} options.data 要修改的数据内容,可选,为空时表示是创建数据
     * @param {string} options.title 数据面板标题,可选
     * @param {number} options.width 数据面板宽度,可选
     * @param {number} options.height 数据面板高度,可选
     * @param {boolean} options.showForm 是否以表单形式显示,可选,默认false
     * @param {Function} options.applyCallback 点击应用按钮的回调函数,可选
     * @returns {any} 返回用户输入的数据, 如果用户点击取消,则返回undefined
     * @example
      * // 弹出数据创建对话框,在控制台输出数据
      * let res = await this.showDataModifyDlg();
      * if (res) {
      * console.log(res)
      * }
      * // 获取图层名称为layer1的数据图层属性,弹出数据修改对话框对其进行修改,数据为图层属性,数据面板以表单形式显示,点击应用按钮回调以及修改结束后,设置图层数据图层属性为修改后的值。
      * let layerName = 'layer1';
      * let property = this.getDataLayerProperty(layerName);
      * let value = await this.showDataModifyDlg({
      * data: property,
      * title: "图层属性",
      * showForm: true,
      * applyCallback: (val) => {
      * this.setDataLayerProperty(layerName, val);
      * }
      * });
      * if (value) {
      * this.setDataLayerProperty(layerName, value);
      * }
     */
    async showDataModifyDlg(options)  {
            options = options || {};
            if (!options.data) {
                // 如果是创建数据,则以json输入框显示
                options.showForm = false;
            }
            return await this.context.ui.showDataModifyDlg(options.data, options.showForm, options);   
         }
    

    /**
     * 根据范围进行闪烁
     * @param {[number,number,number,number]} bounds 范围
     * @param {Object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,默认为#FFFF00参数可选
     * @param {number} options.width 线宽,默认3,参数可选
     * @param {number} options.duration 动画持续时间,默认1000,参数可选
     * @example
      * this.flashBounds([0,0,10,10]);
     */
    flashBounds(bounds, options)  {
            options = options || {};
            return new Promise((resolve => {
               if (Array.isArray(bounds) && bounds.length === 4 && typeof bounds[0] === "number") {
                    bounds = vjmap.GeoBounds.fromArray(bounds);
                } else {
                    bounds = vjmap.GeoBounds.fromDataExtent(bounds);
                }
                const routePath = [];
                routePath.push(bounds.min);
                routePath.push(vjmap.geoPoint([bounds.max.x, bounds.min.y]));
                routePath.push(bounds.max);
                routePath.push(vjmap.geoPoint([bounds.min.x, bounds.max.y]));
                routePath.push(bounds.min);
                let geoLineDatas = [];
                geoLineDatas.push({
                    points: this.map.toLngLat(routePath),
                    properties: {
                        opacity: 1.0
                    }
                })
    
                let polylines = new vjmap.Polyline({
                    data: geoLineDatas,
                    lineColor: options.color || 'yellow',
                    lineWidth: options.width || 3,
                    lineOpacity: ['get', 'opacity'],
                    isHoverPointer: false,
                    isHoverFeatureState: false
                });
                polylines.addTo(this.map);
    
                vjmap.createAnimation({
                    from: 1,
                    to: 10,
                    duration: options.duration || 1000,
                    onUpdate: (e) => {
                        const data = polylines.getData();
                        data.features[0].properties.opacity = parseInt(e) % 2 ? 1.0 : 0 ;
                        polylines.setData(data);
                    },
                    onStop: () => {
                        polylines.remove()
                        resolve({})
                    },
                    onComplete: () => {
                        polylines.remove()
                        resolve({})
                    }
                })
            }))
        }
    

    /**
     * 增加地图全屏控件
     * @param {string} options.container 全屏的容器,参数可选
     * @param {'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} options.position 控件位置,参数可选, 默认'top-right'
     * @example
      * // 增加地图全屏控件,位置左上角
      * this.addMapFullscreenControl({ position: 'top-left' });
     */
    addMapFullscreenControl(options)  {
            options = options || {};
            this.context.global.controls = this.context.global.controls || {};
            if (this.context.global.controls.fullscreenControl) {
                this.map.removeControl(this.context.global.controls.fullscreenControl.control);
            }
            if (options.container) {
                options.container = document.querySelector(options.container);
            }
            let fullscreenControl = new vjmap.FullscreenControl(options);
            this.map.addControl(fullscreenControl, options.position);
            this.context.global.controls.fullscreenControl = {
                control: fullscreenControl,
                position: options.position,
                options: options
            };
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.removeControl(fullscreenControl);
                delete this.context.global.controls.fullscreenControl;
            }); 
        }
    

    /**
     * 在地图范围内随机生成GeoJson数据
     * @param {Record<string, any>} options 参数,参数可选
     * @param {number} boundsType 范围类型(0 地图绘制范围,1 地图实际范围, 2 地图整个范围),默认0, 参数可选
     * @param {string} options.type 类型,值为点 'point',线 'line',面 'polygon', 所有 'all',默认'all'
     * @param {number} options.pointCount 最多点数,默认10
     * @param {number} options.lineCount 最多线数,默认10
     * @param {number} options.polygonCount 最多面数,默认10
     * @param {number} options.linePointCount 每条线上最多点数,默认3
     * @param {number} options.polygonPointCount 每个面最多点数,默认3
     * @returns {Object} 返回GeoJson数据,包含features属性, 每个feature包含geometry和properties属性,properties属性中包含index字段
     * @example
      * // 在地图范围内随机生成GeoJson数据
      * let geojson = this.randomGeojsonInMapBounds();
      * console.log(geojson);
      * // 在地图范围内随机生成GeoJson数据,类型为点,最多生成50个点
      * let ptGeoJson = this.randomGeojsonInMapBounds({
      * type: 'point',
      * pointCount: 50
      * });
      * console.log(ptGeoJson);
     */
    randomGeojsonInMapBounds(options)  {
            options = options || {};
            options.type = options.type || 'all';
            let rect = this.getMapGeoBounds(options.boundsType || 0);
            let geoBounds = vjmap.GeoBounds.fromArray(rect);
            let FeatureCollection = {
                type: "FeatureCollection",
                features: []
            };
        
            if (options.type == 'point' || options.type == 'all') {
                let coll = geoBounds.randomGeoJsonPointCollection(Math.max(options.pointCount || 10, 2));
                if (options.pointCount == 1) {
                    // @ts-ignore
                    FeatureCollection.features.push(coll.features[0]);
                } else {
                    // @ts-ignore
                    FeatureCollection.features.push(...coll.features);
                }
        
            }
            if (options.type == 'line' || options.type == 'all') {
                let coll = geoBounds.randomGeoJsonLineCollection(options.lineCount || 10, options.linePointCount || 3);
                // @ts-ignore
                FeatureCollection.features.push(...coll.features);
            }
            if (options.type == 'polygon' || options.type == 'all') {
                let coll = geoBounds.randomGeoJsonPolygonCollection(options.polygonCount || 10, options.polygonPointCount || 3);
                // @ts-ignore
                FeatureCollection.features.push(...coll.features);
            }
            for(let i = 0; i < FeatureCollection.features.length; i++) {
                let feature = FeatureCollection.features[i];
                feature.id = i;
                feature.properties = {
                    index: i
                }
            }
            return FeatureCollection;
        }
    

    /**
     * 取消测量
     * @example
      * // 取消测量
      * await this.cancelMeasure();
     */
    cancelMeasure()  {
                vjcommon.runMeasureCmd(this.map, "measureCancel");
            }
    

    /**
     * 增加一个点标记Marker
     * @param {[number, number]} pt 要设置的坐标[x, y]
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {string} options.color 颜色,参数可选,默认为#3FB1CE
     * @param {any} options.popupContent 弹窗内容,参数可选,默认为空表示不显示弹窗
     * @param {[number, number]} options.popupOffset 弹窗偏移量,参数可选,默认为[0, -40]
     * @param {boolean} options.popupShowInForm 弹窗内容是否以表单形式显示,参数可 选,默认为false
     * @param {boolean} options.popupOpen 弹窗内容是否打开,参数可选,默认为false
     * @param {number} options.popupWidth 弹窗宽度,参数可选
     * @param {number} options.popupHeight 弹窗高度,参数可选
     * @param {string} options.anchor 锚点, 选项包括'center','top','bottom','left','right','top-left','top-right','bottom-left',和'bottom-right'。参数可选,默认为'center'
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {number} options.rotation 旋转角度,参数可选,默认为0
     * @param {string} options.icon 自定义图标名称,参数可选,默认为空
     * @param {number} options.elevation 坐标标高值,参数可选,默认为0
     * @param {any} options.data 数据内容,参数可选,默认为undefined
     * @param {boolean} options.visible 是否显示,参数可选,默认为true
     * @returns {string} 返回id
     * @example
      * // 示例一
      * // 在坐标[10,20]处添加一个红色的点标记
      * let markerId = this.addMarker([10, 20], {
      * color: "#FF0000"
      * });
      * console.log(markerId);
      * // 示例二
      * // 获取用户数据中的所有点类型的数据,在相应位置添加点标记, 弹窗内容为数据的属性值
      * let data = this.getUserData();
      * let features = data.features.filter(f => f.geometry.type == "Point");
      * features.forEach(f => {
      * this.addMarker(f.geometry.coordinates, {
      * popupContent: f.properties
      * });
      * })
      * // 示例三
      * // 在地图范围内随机生成一个点,在这个位置创建一个marker,图标为sensor,可拖动。
      * let points = this.randomPointInMapBounds(1);
      * let x = points[0][0];
      * let y = points[0][1];
      * this.addMarker([x, y], {
      * draggable: true,
      * icon: "sensor"
      * });
     */
    addMarker(pt, options)  {
            options = options || {};
            let element;
            if (options.icon) { 
                // 获取自定义图标数据, 在工具栏中的"地图图像管理"中对自定义图标进行管理
                let image = this.context.ui.getCustomImages(options.icon);
                if (image) {
                    let el = document.createElement('div');
                    el.className = 'marker';
                    let imgValue = image.value;
                    if (imgValue.toLowerCase().indexOf("<svg") == 0) {
                        //svg或//base64 png
                        imgValue =  "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(imgValue))) ;
                    }
                    el.style.backgroundImage =
                    `url("${imgValue}")`;
                    el.style.width = (image.width ?? 40) + 'px';
                    el.style.height = (image.height ?? 40) + 'px';
                    el.style.backgroundSize = '100%';
                    element = el;
                }
            }
            let marker = new vjmap.Marker({
                color: options.color,
                anchor: options.anchor,
                draggable: options.draggable,
                rotation: options.rotation,
                element: element
            })
            marker.setLngLat(this.map.toLngLat(pt));
            marker.addTo(this.map);
            marker.id = "marker_" + vjmap.RandomID()
            if (options.data) marker.data = options.data;
            if (options.elevation) marker.setHeight(options.elevation);
    
            if (options.popupContent) {
                let popup = new vjmap.Popup({
                    offset: options.popupOffset || [0, -40]
                })
                const dom = this.context.ui.createElementByJsonData(options.popupContent, options.popupShowInForm, {
                    width: options.popupWidth,
                    height: options.popupHeight
                })
                popup.setDOMContent(dom.element)
                marker.setPopup(popup)
                if (options.popupOpen) {
                    marker.togglePopup()
                }
            }
            if (options.visible !== undefined) {
                marker.setVisible(options.visible, true);
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteMarker(marker.id);
            });
            return marker.id
        }
    

    /**
     * 根据根据的坐标位置直接绘制一个点符号
     * @param {[number, number]} point 点符号的坐标[x, y],参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {number} options.size 点大小,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 在位置[10, 20]处绘制一个点
      * const pt = this.createPoint([10, 20]); // 启用捕捉功能采绘制一个点坐标
      * if (!pt) return;
      * // 点的坐标
      * let point = pt.point;
      * const x = point[0];
      * const y = point[1];
      * console.log(x, y);
      * // 图元ID
      * let id = pt.id;
      * console.log(id);
      * // 示例二
      * // 在地图范围内随机生成1个点, 在这个点绘制一个点,颜色为红色,大小为10,数据值为123
      * let points = this.randomPointInMapBounds(1);
      * const pt2 = this.createPoint(points[0], {
      * color: "#FF0000",
      * size: 10,
      * data: 123
      * });
      * console.log(pt2);
     */
    createPoint(point, options)  {
            options = options || {};
            let draw = this.map.getDrawLayer();
            let id = vjmap.RandomID(10)
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: 'Point',
                    coordinates: this.map.toLngLat(point)
                },
                properties: {
                    "color_static": options.color,
                    "radius_static": options.size,
                    "data": options.data
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                point
            };
        }
    

    /**
     * 创建曲线数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.lineColor 线条颜色,参数可选,默认为'#ff0000'
     * @param {number} options.lineWidth 线宽,参数可选,默认为1
     * @param {number} options.lineOpacity 线透明度,参数可选,取值范围0-1
     * @param {number} options.lineGapWidth 线间隙宽度,参数可选,默认为1,单位像素
     * @param {number} options.lineOffset 线的偏移量,参数可选。正值向右/内偏移,负值向左/外偏移
     * @param {number} options.lineBlur 线模糊度,参数可选,需小于线宽度
     * @param {[number,number]} options.lineDasharray 虚线样式,参数可选,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,参数可选,格式如[x,y],负数表示左和上,单位像素
     * @param {string} options.lineCap 线帽形状,参数可选,可选值:'butt'(尖头)、'round'(圆头)、'square'(平头)
     * @param {string} options.lineJoin 拐角形状,参数可选,可选值:'bevel'(平拐)、'round'(圆拐)、'miter'(棱拐)
     * @param {string} options.linePattern 线图案,参数可选,需与预加载的图片名称对应,图像宽度必须是2的幂次
     * @param {string} options.lineGradient 线渐变,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer8的曲线数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createCurveLayer(geojson, {
      * layerName: 'layer8'
      * });
      * console.log(layer);
     */
    async createCurveLayer(data, options)  {
            options = options || {};
            let type = "curve";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                lineColor: '#00ffff',
                lineWidth: 3,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createCurveLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 根据给定的点坐标数组直接绘制一条线
     * @param {[number, number][]} points 线的坐标点数组[[x1,y1],[x2,y2],...],参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {number} options.width 线宽,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Object} 返回绘制的图元对象,返回的对象包含以下属性:
     * @example
      * // 根据三个地图上面的随机点创建一条线, 线的宽度为2-5,颜色红色
      * let points = this.randomPointInMapBounds(3); // 每条线3个点
      * const line = this.createLineString(points, {
      * color: vjmap.randomColor(),
      * width: 2 + Math.random() * 3
      * });
      * console.log(`线 ID:`, line.id);
      * console.log(`线 点坐标:`, line.points);
     */
    createLineString(points, options)  {
            let draw = this.map.getDrawLayer();
            let id = vjmap.RandomID(10);
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: 'LineString',
                    coordinates: points.map(pt => this.map.toLngLat(pt))
                },
                properties: {
                    color: options.color,
                    line_width: options.width,
                    data: options.data
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                points
            };
        }
    

    /**
     * 将CAD图几何坐标转换为地图像素点坐标
     * @returns {[number, number]} 返回包含两个数字的数组[x,y],表示地图像素点坐标
     * @example
      * // 将CAD图几何坐标[1000, 2000]转换为地图像素点坐标
      * let pixel = this.geoPointToPixelPoint([1000, 2000]);
      * let x = pixel[0];
      * let y = pixel[1];
      * console.log(x, y);
     */
    geoPointToPixelPoint(pt)  {
            let lngLat = this.map.toLngLat(pt);
            let pixelPoint = this.map.project(lngLat);
            return [pixelPoint.x, pixelPoint.y];
        }
    

    /**
     * 自动提取子图范围
     * @returns {Promise<Object>} 如果失败则返回undefined, 否则返回提取出的子图范围的GeoJSON数据和子图范围的bounds数组, 返回格式如下:
     * @example
      * // 自动提取子图范围
      * let res = await this.findChildMapRects();
      * console.log(res);
     */
    async findChildMapRects(options)  {
            options = options || {};
           let svc = this.map.getService();
           options = {
            mapid: options.mapid || svc.currentMapParam().mapid,
            bounds: "",
            condition: "",
            debugInfo: [],
            digit: 4,
            tol: 0,
            tableEdgeMinPoint: 12,
            tableTextMinCount: 4,
            cellMaxArea: 90,
            cellEmptyRatio: 90,
            unLinkLineRatio: 20,
            tableMaxCellCount: 100000,
            noHvLineSegCount: 0,
            seachTableMost: false,
            version:  svc.currentMapParam()?.version,
            layer: svc.currentMapParam()?.layer,
            // 如果直接内存打开的话,用表达式查询,如果几何渲染打开,用空间查询
            geom: svc.currentMapParam()?.mapopenway != vjmap.MapOpenWay.Memory,
            ...options,
           };
           if (options.isSelectBounds) {
                // 如果是手动,先在图中选择一个区域
                if (this.map.logInfo) this.map.logInfo("请先选择表格所在的矩形区域,选择区域的范围需要覆盖表格内容", "success", 10000);
                 // 先在地图上绘制一个矩形,做为裁剪区域
                let snapObj = {}; // 设置的捕捉的实体
                vjcommon.getMapSnapPoints(this.map, snapObj);
                let res = await vjmap.Draw.actionDrawRectangle(this.map, {
                    api: {
                        getSnapFeatures: snapObj //要捕捉的数据项在后面,通过属性features赋值
                    },
                    contextMenu: (e) => {
                        // 给地图发送Enter键消息即可取消,模拟按Enter键
                        this.map.fire("keyup", {keyCode:13})
                    }
                });
                if (res.cancel) {
                    return // 取消操作
                }
                // 获取所绘制的坐标
                let rectCoord = this.map.fromLngLat(res.features[0].geometry.coordinates[0]);
                // 取左下角和右下角两个点
                let  bounds = [rectCoord[0].x, rectCoord[0].y, rectCoord[2].x, rectCoord[2].y];
                options.bounds = bounds.join(',');
           }
           if (Array.isArray(options.bounds)) {
            options.bounds = JSON.stringify(options.bounds);
           }
           if (options.showSettingForm === true) {
            options = await this.showDataModifyDlg({
                data: options,
                title: "自动提取表格设置",
                showForm: true
            })
            if (!options) return;
           }
           // 只获取子图范围
           options.findChildMapRects = true;
           let result = await svc.cmdExtractTale(options);
           if (result && result.error) {
                if (this.map.logInfo) this.map.logInfo(result.error, "error", 10000);
                return;
           }
           if (!result.childMapRects) return;
           let geoDatas = {
                "type": "FeatureCollection",
                "features": []
            }
           let childMapBounds = [];
           for (let i = 0; i < result.childMapRects.length; i++) {
               let bounds = vjmap.GeoBounds.fromArray(result.childMapRects[i].bounds);
               childMapBounds.push(bounds.toString())
               let points = bounds.toPointArray();
               points.push(points[0]); // 闭合
               geoDatas.features.push({
                   type: "Feature",
                   geometry: {
                       type: "Polygon",
                       coordinates: [points]
                   },
                   properties: {
                       color: vjmap.randomColor(),
                       index: i,
                       data: result.childMapRects[i]
                   }
               });
           }
           return {
            geojson: geoDatas,
            childMapBounds: childMapBounds
           }
    
        }
    

    /**
     * 设置地图的中心坐标
     * @param {[number, number]} point 中心点坐标,格式为[x,y]
     * @example
      * this.setCenter([100, 20]); // 设置中心坐标为x为100,y为20
     */
    setCenter(point)  {
            let oldCenter = this.map.fromLngLat(this.map.getCenter()) ; // 获取当前中心坐标
            this.map.setCenter(this.map.toLngLat(point)); // 设置新的中心坐标
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.setCenter(this.map.toLngLat(oldCenter));
            });
        }
    

    /**
     * 设置地图的缩放级别
     * @param {number} zoom 要设置的缩放级别
     * @example
      * this.setZoom(10); // 设置缩放级别为10
      * // 将级别放大一级
      * let zoom = this.getZoom(); // 获取原来的级别
      * zoom = zoom + 1; // 放大一级
      * this.setZoom(zoom);
     */
    setZoom(zoom)  {
            let oldZoom = this.map.getZoom(); // 获取当前缩放级别
            this.map.setZoom(zoom) // 设置新的缩放级别
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.setZoom(oldZoom);
            });
        }
    

    /**
     * 创建或更新地图,通过图的fileid、url地址或手动选择本地图纸创建或更新地图
     * @param {object} options 参数 可选
     * @param {string} options.fileid 图纸的fileid, 为空时则手动选择本地图纸, 可以是一个url地址或文件id
     * @param {string} options.mapid 地图id 可选,为空时则自动生成mapid
     * @param {"Memory" | "GeomRaster" | "GeomVector"} options.openway 打开方式 可选,Memory: 内存, GeomRaster: 栅格, GeomVector: 矢量, 默认栅格
     * @param {boolean} options.lightTheme 是否使用浅色主题 可选,为空时则使用深色主题
     * @param {boolean} options.isFullExtent 是否全图范围显示 可选,默认false
     * @returns {Object | undefined} 返回对象,包含地图id和版本和fileid {mapid: string, version: string, fileid: string}, 如果取消则返回undefined
     * @example
      * // 手动选择本地图纸创建地图
      * await this.createOrUpdateMap();
      * // 通过url地址创建地图,url地址为https://vjmap.com/static/assets/data/gym.dwg, mapid为newgym,以矢量方式打开, 使用深色主题
      * await this.createOrUpdateMap({
      * fileid: "https://vjmap.com/static/assets/data/gym.dwg",
      * mapid: "newgym",
      * openway: "GeomVector",
      * lightTheme: false
      * });
     */
    async createOrUpdateMap(options)  {
            options = options || {};
            let fileid = options.fileid || "";
            let svc = this.map.getService();
            let uploadname;
            if (!fileid) {
                let formats = await svc.cmdGetSupportFormat();
                let acceptFormat = '';
                if (formats.cad) {
                    acceptFormat = formats.cad.split(";").map(f => '.' + f).join(",")
                }
                if (formats.image) {
                    acceptFormat += "," + formats.image.split(";").map(f => '.' + f).join(",")
                }
                const selectFile = () => {
                    return new Promise((resolve, reject) => {
                        // 创建一个隐藏的文件输入元素
                        const input = document.createElement('input');
                        input.type = 'file';
                    
                        // 设置允许选择的文件类型
                        input.accept = acceptFormat;
                    
                        // 添加事件监听器,当用户选择文件时触发
                        input.addEventListener('change', () => {
                        if (input.files && input.files.length > 0) {
                            resolve(input.files[0]); // 返回选中的第一个文件对象
                        } else {
                            reject(new Error('No file selected'));
                        }
                        });
                    
                        // 触发文件选择窗口
                        input.click();
                    });
                }
                try {
                    // 选择文件 
                    let file = await selectFile();
                    // 上传文件
                    let res = await svc.uploadMap(file);
                    if (res && res.error) {
                        this.showMessage(res.error)
                        return;
                    }
                    fileid = res.fileid;
                    uploadname = res.uploadname;
                }
                catch(err) {
                    this.showMessage(err)
                    return;
                }
            }
            let mapid = options.mapid || "";
            if (!mapid) {
                mapid = fileid;
                // 如果是url地址
                if (fileid.toLowerCase().endsWith('.dwg')) {
                    mapid = svc.strMd5(fileid).substring(0, 16);
                }
            }
            let mapopenway =  options.openway === "Memory" ? vjmap.MapOpenWay.Memory : vjmap.MapOpenWay.GeomRender;
            let isVectorStyle = options.openway === "GeomVector" ? true : false;
            let lightTheme = options.lightTheme ?? (this.map.getService().currentMapParam()?.darkMode === true ? false : true)
          
            this.showMessage("正在打开地图中,请稍等...", "success")
            // 打开地图
            let result = await svc.updateMap({
                mapid: mapid,
                fileid: fileid,
                mapopenway: mapopenway,
                uploadname: uploadname,
                style: lightTheme ? vjmap.openMapLightStyle() : vjmap.openMapDarkStyle(),
            });
    
            // 切换成新图
            let res = await this.map.switchMap({
                mapid: result.mapid,
                version: result.version,
                mapopenway: mapopenway,
                style: lightTheme ? vjmap.openMapLightStyle() : vjmap.openMapDarkStyle()
            }, false, isVectorStyle, true, true);
            if (options.isFullExtent !== true) {
                // 用默认的中心点和缩放级别参数
                let svc = this.map.getService();
                let param = svc.currentMapParam();
                if (param && param.view) {
                    if (param.view.center) {
                        this.map.setCenter(param.view.center);
                    }
                    if (param.view.zoom) {
                        this.map.setZoom(param.view.zoom);
                    }
                    if (param.view.bearing) {
                        this.map.setBearing(param.view.bearing);
                    }
                }
            }
            if (res && res.error) {
                this.showMessage(res.error)
                return;
            }
            // 打开新的地图了,需要清空历史记录
            this.context.ui.clearUndoRecord();
            return {
                mapid: result.mapid,
                fileid: fileid,
                version: result.version
            };
    
        }
    

    /**
     * 比较地图不同
     * @param {Object} options 参数
     * @param {string} options.mapid1 地图一ID,可选,如为空时,则使用当前打开的地图
     * @param {string} [options.version1] 地图一版本(为空时采用当前打开的地图版本)
     * @param {string} [options.layer1] 地图一样式图层,可选,如为空时,则使用当前打开的地图样式名称
     * @param {string} options.mapid2 地图二ID,可选,如为空时,则使用当前打开的地图
     * @param {string} [options.version2] 地图二版本(为空时采用当前打开的地图版本)
     * @param {string} [options.layer2] 地图二样式图层,可选,如为空时,则使用当前打开的地图样式名称
     * @param {boolean} [options.noCompareNew] 不比较新增部分
     * @param {boolean} [options.noCompareDelete] 不比较删除部分
     * @param {number} [options.size] 比较大小. 默认 4096
     * @param {number} [options.cellsize] 比较单元大小. 默认 10
     * @param {number} [options.diffMinPixel] 不同的像素最小值. 默认  0
     * @param {number} [options.diffMinAlpha] 不同的透明最小值.  默认 25
     * @param {number} [options.diffMinColor] 不同的颜色最小值. 默认 6
     * @returns {Promise<Object>} 返回比较结果, 如果失败则返回undefined, 如果成功则返回字段如下:
     * @example
      * // 示例
      * // 比较当前地图和sys_hello的不同
      * let res = await this.findMapDiff({
      * mapid2: "world"
      * });
      * console.log(res);
     */
    async findMapDiff(options)  {
           options = options || {};
           let svc = this.map.getService();
           options.mapid1 = options.mapid1 || svc.currentMapParam().mapid;
           options.mapid2 = options.mapid2 || svc.currentMapParam().mapid;
           let res = await svc.cmdMapDiff(options);
           if (res && res.status) {
            const toGeoJSON = (points) => {
                let geojson = {
                    type: "FeatureCollection",
                    features: []
                };
                if (!points || points.length === 0) return geojson;
                points.forEach(p => {
                    if (p.length > 0) {
                        p.push(p[0]);
                    }
                    geojson.features.push({
                        type: "Feature",
                        geometry: {
                            type: "LineString",
                            coordinates: p
                        }
                    });
                }) ;// 闭合
                
                
                return geojson;
            }
            let result = {
                new: toGeoJSON(res.new),
                modify: toGeoJSON(res.modify),
                del: toGeoJSON(res.del),
                diff: toGeoJSON([...res.new, ...res.modify, ...res.del])
            };   
            return result;
           }
           return undefined;
       }
    

    /**
     * /**
     * @returns {Object} 返回一个对象,包含三个布尔值,分别表示Shift、Ctrl、Alt键是否被按下
     * @example
      * // 示例一
      * // 当前Shift键是否按下
      * let key = this.isShiftCtrlAltKeyPressed();
      * if (key.shift) {
      * console.log("Shift键被按下");
      * }
      * // 示例二
      * // 监听地图单击事件,如果Ctrl键被按下,获取点击的CAD图几何坐标位置,根据位置弹出数据信息框,标题为"点击位置",以表单形式展示
      * this.listenMapEvent("click", async ev => {
      * // 获取当前是否按下Ctrl键
      * let key = this.isShiftCtrlAltKeyPressed();
      * if (key.ctrl) {
      * if (ev && ev.point) {
      * // 获取当前地图的像素坐标,转换为CAD图几何坐标
      * const point =  this.pixelPointToGeoPoint(ev.point);
      * // 根据位置弹出数据信息框,标题为"点击位置",以表单形式展示
      * await this.showDataInfoDialog(point, true, "点击位置");
      * }
      * }
      * }, true);
     */
    isShiftCtrlAltKeyPressed()  {
            let shift = false, ctrl = false, alt = false;
            if (this.context.global.__listenKeyEvent) {
                shift = this.context.global.__listenKeyEvent.isShiftKey();
                ctrl = this.context.global.__listenKeyEvent.isCtrlKey();
                alt = this.context.global.__listenKeyEvent.isAltKey();
            }
            return {
                shift: shift,
                ctrl: ctrl,
                alt: alt,
            };
        }
    

    /**
     * 采集三维多段线
     * @param {object} options 参数
     * @param {number} options.searchRadiusRatio 搜索文字范围半径倍数,默认2
     * @param {boolean} isSnap 是否启用捕捉绘制的点, 默认true
     * @param {boolean} isSnapMap 是否启用捕捉图上的点 默认false
     * @example
      * // 采集三维多段线
      * await this.pick3dPolylines();
     */
    async pick3dPolylines(options)  {
            // --采集三维线--采集时可自动搜索文字获取当前点的高程值
            // 采集的坐标转成 [x,z,y]格式,可参考此示例自动生成三维管道
            // https://vjmap.com/map3d/demo/#/demo/this.map/builtin/objects/03builtinobjtubepath
            options = options || {};
            let svc = this.map.getService();
            let mapAllTexts;
            let textMeanHeight = 0; // 图中文字平均高
            const getAllTexts = async ()=> {
                if (mapAllTexts) return mapAllTexts; // 如果获取过了
                // 实体类型ID和名称映射
                const { entTypeIdMap } = await svc.getConstData();
                const getTypeNameById = name => Object.keys(entTypeIdMap).find(e => entTypeIdMap[e] === name);
    
                let queryTextEntTypeId = getTypeNameById("AcDbText"); // 单行文字
                let queryMTextEntTypeId = getTypeNameById("AcDbMText"); // 多行文字
                let queryAttDefEntTypeId = getTypeNameById("AcDbAttributeDefinition"); // 属性定义文字
                let queryAttEntTypeId = getTypeNameById("AcDbAttribute"); // 属性文字
                let query = await svc.conditionQueryFeature({
                    condition: `name='${queryTextEntTypeId}' or name='${queryMTextEntTypeId}' or name='${queryAttDefEntTypeId}' or name='${queryAttEntTypeId}'`, // 只需要写sql语句where后面的条件内容,字段内容请参考文档"服务端条件查询和表达式查询"
                    fields: "objectid,envelop,text",
                    geom: true,
                    limit: 100000 //设置很大,相当于把所有的圆都查出来。不传的话,默认只能取100条
                })
                if (query.error) {
                    this.map.logInfo(query.error, "error");
                    return;
                } else {
                    mapAllTexts = []
                    textMeanHeight = 0
                    if (query.recordCount > 0) {
                        for(let i = 0; i < query.recordCount; i++) {
                            let bounds = this.map.getEnvelopBounds(query.result[i].envelop);
                            mapAllTexts.push({
                                position: bounds.center(),
                                text: query.result[i].text
                            });
                            textMeanHeight += bounds.height()
                        }
                        textMeanHeight = textMeanHeight / query.recordCount
                    }
                }
                return mapAllTexts
            }
        
            function isNumeric(value) {
                const regex = /^[0-9]*\.?[0-9]+$/;  // 匹配数字和一个小数点的模式
                return regex.test(value);
            }
            
            let snapObj = {};
            const collect3Dlines = async () => {
                // 给地图发送ESC键消息即可取消,模拟按ESC键,如果之前在采集,先取消之前的
                this.map.fire("keyup",{keyCode:27})
                this.map.logInfo("请在图上采集线,按回车键或右键菜单里确认结束")
                let elevations = []
                if (options.isSnapMap && !snapObj.features) {
                    vjcommon.getMapSnapPoints(this.map, snapObj);
                }
                let line = await vjmap.Draw.actionDrawLineSting(this.map, {
                    snap: options.isSnap === false ? false : true,
                    api: {
                        getSnapFeatures: snapObj
                    },
                    updatecoordinate: async (e) => {
                        if (!e.lnglat) return;
                        if (e.isClick) {
                            let curIdx = e.feature.coordinates.length - 1
                            const co = this.map.fromLngLat(e.feature.coordinates[curIdx]);
                            // 获取当前点旁边所有的文字
                            let allTexts = await getAllTexts()
                            let radius = textMeanHeight * (options.searchRadiusRatio || 2); // 以文字平均高度的2倍做为搜索距离 这个数值根据实际情况调节
                            // 先根据是否是数字,再根据距离过滤
                            let texts = allTexts.filter(item => isNumeric(item.text)).filter(item => vjmap.geoPoint(co).distanceTo(item.position) <= radius)
                            texts = texts.map(t => t.text); // 只获取内容
                            // 弹出输入框,并获取用户输入
                            let elevation = await this.context.ui.selectSuggestionValue(texts, {mustNumber: true, title: "请选择或输入高程值"})
                            if (elevation === undefined) {
                                // 取消采集
                                this.map.fire("keyup",{keyCode:27})
                                return;
                            }
                            elevations.push(elevation)
                        }
    
                    }, contextMenu: (e) => {
                        new vjmap.ContextMenu({
                            event: e.event.originalEvent,
                            theme: "dark", //light
                            width: "250px",
                            items: [
                                {
                                    label: '确认',
                                    onClick: () => {
                                        // 给地图发送Enter键消息即可取消,模拟按Enter键
                                        this.map.fire("keyup", { keyCode: 13 })
                                    }
                                },
                                {
                                    label: '取消',
                                    onClick: () => {
                                        // 给地图发送ESC键消息即可取消,模拟按ESC键
                                        this.map.fire("keyup", { keyCode: 27 })
                                    }
                                }, {
                                    label: '删除上一个点',
                                    onClick: () => {
                                        // 给地图发送退格键Backspace消息即可删除上一个点,模拟按Backspace键
                                        this.map.fire("keyup", { keyCode: 8 })
                                        elevations.pop(); // 删除最后一个元素
                                    }
                                }, {
                                    label: '结束',
                                    onClick: () => {
                                        // 给地图发送ESC键消息即可取消,模拟按ESC键
                                        this.map.fire("keyup", { keyCode: 27 })
                                    }
                                }
                            ]
                        });
    
                    }
                })
                if (line.cancel) {
                    return // 取消操作
                }
    
                let feature = line.features[0]
                feature.properties.elevations = elevations;
                feature.properties.typename = "3dpolyline"
                feature.properties.line_width = 12;
                feature.properties.color = vjmap.randomColor()
                this.map.getDrawLayer().add(feature) 
    
                if (options.isSnap !== false) {
                    // 把绘制的线加进捕捉
                    snapObj.features = snapObj.features || [];
                    snapObj.features.push({
                        type: "Feature",
                        geometry: {
                            type: "LineString",
                            coordinates: feature.geometry.coordinates
                        }
                    });
                }
            }
    
            this.addButtonItem("开始采集", async () => {
                await collect3Dlines()
            })
    
            this.addButtonItem("获取三维线数据", async () => {
                let data = this.map.getDrawLayer().getAll();
                data = this.map.fromLngLat(data);
                let features = data.features.filter(item => item.properties.typename === "3dpolyline") || [];
                let result = [];
                for(let i = 0; i < features.length; i++) {
                    let coords = features[i].geometry.coordinates;
                    let elevations = features[i].properties.elevations;
                    let data = coords.map((co, idx) => [co[0], co[1], elevations[idx]]);
                    result.push({
                        paths: data,
                        name: i
                    })
                }
                await this.showDataInfoDialog(result, false, "三维线数据")
            })
    
            this.addButtonItem("退出采集", async () => {
                // 取消采集
                this.map.fire("keyup",{keyCode:27})
                let data = this.map.getDrawLayer().getAll();
                data.features = data.features.filter(item => item.properties.typename !== "3dpolyline")
                this.map.getDrawLayer().set(data);
                this.removeButtonItem("开始采集")
                this.removeButtonItem("获取三维线数据")
                this.removeButtonItem("退出采集")
            })
    
        }
    

    /**
     * 查询图中数据
     * @param {string} sql sql语句,数据库表名称为geom, 表结构如下
     * @returns {Object} 返回标准的GeoJson格式的FeatureCollection对象, 包含features属性, 每个feature包含geometry和properties属性,properties属性中包含如下字段:
     * @example
      * // 示例一
      * // 查询图中类型为 line 且图层索引为 2 的记录
      * let result1 = await  this.queryMapData("SELECT * FROM geom WHERE name = 'AcDbLine' AND layerIndex = 2");
      * if (result1.features.length > 0) {
      * let feature = result1.features[0];
      * // 获取线宽
      * console.log(feature.properties.lineWidth)
      * // 获取所有点的坐标,在坐标处绘制一个Marker
      * const addMarker = (co) => {
      * // co的格式为[x, y]
      * this.addMarker(co)
      * }
      * const processGeoJSONFeature = (geometry) => {
      * if (geometry.type === "Point") {
      * let co = geometry.coordinates;
      * addMarker(co)
      * } else if (geometry.type === "MultiPoint") {
      * geometry.coordinates.forEach(co => addMarker(co))
      * } else if (geometry.type === "LineString") {
      * geometry.coordinates.forEach(co => addMarker(co))
      * } else if (geometry.type === "MultiLineString") {
      * geometry.coordinates.forEach(line => {
      * line.forEach(co => addMarker(co))
      * })
      * } else if (geometry.type === "Polygon") {
      * geometry.coordinates.forEach(line => {
      * line.forEach(co => addMarker(co))
      * })
      * } else if (geometry.type === "MultiPolygon") {
      * geometry.coordinates.forEach(polygon => {
      * polygon.forEach(line => {
      * line.forEach(co => addMarker(co))
      * })
      * })
      * }
      * }
      * if (feature.geometry.type === "GeometryCollection") {
      * feature.geometry.geometries.forEach(ft => {
      * processGeoJSONFeature(ft)
      * })
      * } else {
      * processGeoJSONFeature(feature.geometry)
      * }
      * }
      * // 示例二
      * // 查询图中全部文本,坐标类型为几何坐标
      * let result2 = await this.queryMapData("SELECT * FROM geom WHERE (name = 'AcDbText' or name = 'AcDbMText' or name = 'AcDbAttributeDefinition' or name = 'AcDbAttribute')  and coordType = true");
      * if (result2.features.length > 0) {
      * result2.features.forEach(feature => {
      * // 获取文本内容
      * console.log(feature.properties.content)
      * });
      * }
      * // 查询图中包含矩形范围为[10, 10, 20, 20]的全部线,坐标类型为位置坐标
      * let result3 = await this.queryMapData("SELECT * FROM geom WHERE  (name = 'AcDbLine' or name = 'AcDbPolyline' or name = 'AcDb2dPolyline' or name = 'AcDb3dPolyline') and bounds ='[10, 10, 20, 20]' and isContains = true  and coordType = false");
      * // 获取记录总数
      * console.log(result3.features.length)
     */
    queryMapData(sql)  {
            return this.context.tools.queryMapData(this.context, sql)
        }
    

    /**
     * 获取当前地图服务版本号和运行环境信息
     * @example
      * // 获取当前地图服务版本号和运行环境信息, 获取返回数据弹出数据信息框,标题为地图服务版本信息,以表单格式显示
      * let res = await this.getMapServerInfo();
      * if (res) {
      * await this.showDataInfoDialog(res, true, "地图服务版本信息");
      * }
     */
    async getMapServerInfo()  {
            let svc = this.map.getService();
            const _url = svc.baseUrl() + "version";
            let res = await svc._get(_url, {});
            if (res && "data" in res) {
                let data =  res["data"];
                return {
                    version: data.version,
                    os: data.os,
                    arch: data.arch
                };
            }
         }
    
    

    /**
     * 增加小地图(鹰眼)控件
     * @param {'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} options.position 控件位置,参数可选, 默认'top-right'
     * @example
      * // 增加小地图(鹰眼)控件,位置左下角
      * this.addMiniMapControl({ position: 'bottom-left' });
     */
    addMiniMapControl(options)  {
            this.context.global.controls = this.context.global.controls || {};
            if (this.context.global.controls.miniMapControl) {
                this.map.removeControl(this.context.global.controls.miniMapControl.control);
            }
            let transformOrigin = "100% 0%";
            if (options.position === 'top-left') {
                transformOrigin = "0% 0%";
            } else if (options.position === 'bottom-right') {
                transformOrigin = "100% 100%";
            } else if (options.position === 'bottom-left') {
                transformOrigin = "0% 100%";
            }
            let miniMapControl = new vjmap.MiniMapControl({
                containerStyle: {
                    background: "#31346a85",
                    transform: "scale(0.6)",
                    transformOrigin: transformOrigin
                },
                ...options
            });
            this.map.addControl(miniMapControl, options.position);
            this.context.global.controls.miniMapControl = {
                control: miniMapControl,
                position: options.position,
                options: options
            };
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.removeControl(miniMapControl);
                delete this.context.global.controls.miniMapControl;
            }); 
        }
    

    /**
     * 导出为PDF文件
     * @param {Object} options 导出PDF的选项,参数可选
     * @param {string} options.mapid 地图id,默认当前地图
     * @param {string} options.version 地图版本,默认当前地图版本
     * @param {boolean} options.exportDrawLayer 是否导出绘图图层,默认false
     * @param {boolean} options.bIncludeOffLayers 是否包含关闭的图层,默认false
     * @param {boolean} options.bSearchableSHX 是否包含可搜索型文字,默认false
     * @param {boolean} options.bSearchableTTF 是否包含可搜索ttf文字,默认false
     * @param {number} options.pageWidth 页面宽度,单位mm,默认210 (A4)
     * @param {number} options.pageHeight 页面高度,单位mm,默认297 (A4)
     * @param {number} options.pageLeftMargin 左页边距,单位mm,默认0
     * @param {number} options.pageRightMargin 右页边距,单位mm,默认0
     * @param {number} options.pageTopMargin 上页边距,单位mm,默认0
     * @param {number} options.pageBottomMargin 下页边距,单位mm,默认0
     * @param {number} options.geomDPI 矢量图形DPI,默认600
     * @param {number} options.colorImagesDPI 图像DPI,默认400
     * @param {boolean} options.isBlackWhiteMode 是否导出为黑白模式,默认false
     * @param {boolean} options.isGrayMode 是否导出为灰色模式,默认false
     * @param {boolean} options.disableOpen 只返回地址,不打开图片,默认false
     * @example
      * // 示例一
      * // 导出为PDF文件
      * await this.exportPdf();
      * // 示例二
      * // 导出为PDF文件, 并包含绘图图层
      * await this.exportPdf({exportDrawLayer: true});
      * // 示例三
      * // 导出为PDF文件, mapid为sys_world, 灰度模式
      * await this.exportPdf({mapid: "sys_world", isGrayMode: true});
     */
    async exportPdf(options)  {
            this.showMessage("正在导出Pdf并打开,请稍候...", "info" );
            options = options || {};
            let mapid = options.mapid || this.map.getService().currentMapParam()?.mapid;
            let version = options.version || this.map.getService().currentMapParam()?.version;
            if (!options.mapid &&options.exportDrawLayer === true) {
              const res = await vjcommon.exportDwg(this.map, this.map.getDrawLayer());
              if (res.error) {
                  this.showMessage(res.error, "error" );
                  return;
              }
              mapid = res.mapid;
              version = res.version;
            }
    
            let param = options; // 不填的话,用默认的
            /*
            param = {
                bIncludeOffLayers: false, // 是否包含关闭的图层
                bSearchableSHX: false, // 可搜索型文字
                bSearchableTTF: false, // 可搜索ttf文字
                pageWidth: 210, // 宽,单位mm
                pageHeight: 297, // 高,单位mm
                pageLeftMargin: 0, // 左页边距 (pageWidth, pageHeight有值时有效)
                pageRightMargin: 0, // 右页边距 (pageWidth, pageHeight有值时有效)
                pageTopMargin: 0, // 上页边距 (pageWidth, pageHeight有值时有效)
                pageBottomMargin: 0, // 下页边距 (pageWidth, pageHeight有值时有效)
                geomDPI: 600, // 矢量dpi
                colorImagesDPI: 400, //图像dpi
                isBlackWhiteMode: false, // 是否导出为黑白模式
                isGrayMode: false, // 是否导出为灰色模式
            }*/
            let svc = this.map.getService();
            const result = await svc.execCommand("exportPdf", param, mapid, version, true);
            if (result.error) {
                this.map.logInfo(result.error, "error");
            } else {
                let pdfUrl = svc.baseUrl() + result.path + "?token=" + svc.accessToken;
                if (!options.disableOpen) {
                    window.open(pdfUrl )
                }
                return pdfUrl;
            }
          }
    

    /**
     * 根据图层名称和数据内容更新数据图层数据值
     * @param {string} layerName 图层名称,参数必填
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @example
      * // 更新图层名称为layer1的数据图层数据为随机生成的GeoJson数据
      * let layerName = 'layer1';
      * let geojson = this.randomGeojsonInMapBounds();
      * this.updateDataLayerSource(layerName, geojson);
     */
    updateDataLayerSource(layerName, data)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item) {
                item.data = data;
                let oldData = {...item.data};
    
                let layerId = item.layerId;
                let sourceId = item.sourceId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                    let style = this.map.getStyle();
                    let layer = style.layers.find(layer => layer.id == layerId);
                    if (layer && layer.source) {
                        sourceId = layer.source;
                    }
                }
    
                this.map.setData(sourceId, this.map.toLngLat(data));
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.updateDataLayerSource(layerName, oldData);
                });
            }
        }
    

    /**
     * 设置地图是否显示线宽
     * @param {boolean} isShowLineWidth 是否显示线宽
     * @example
      * // 设置地图显示线宽
      * await this.setMapShowLineWidth(true);
      * // 设置地图不显示线宽
      * await this.setMapShowLineWidth(false);
     */
    async setMapShowLineWidth(isShowLineWidth)  {
            if (!this.context.global.updateMapStyleObj) {
                this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
            }
            const updateMapStyleObj = this.context.global.updateMapStyleObj;
            const oldLineweight = updateMapStyleObj.getCurStyle()?.lineweight;
            await updateMapStyleObj.updateStyle({
                lineweight: isShowLineWidth ? 1 : 0
            })
            // 添加撤销记录
            this.context.ui.addUndoRecord(async () => {
                await updateMapStyleObj.updateStyle({
                    lineweight: oldLineweight
                })
            });
        }
    

    /**
     * 导出当前图形指定范围的图片
     * @param {[number, number, number, number]} bounds 范围,格式为[minx, miny, maxx, maxy]
     * @param {object} options 导出图片的选项,参数可选
     * @param {number} options.pictureWidth 图片宽度,单位像素, 默认1024
     * @param {number} options.scale 缩放比例,默认1.01
     * @param {boolean} options.transparent 是否透明背景,默认false
     * @param {string} options.backgroundColor 背景颜色,默认'rgb(0,0,0)'
     * @param {boolean} options.disableOpen 只返回地址,不打开图片,默认false
     * @example
      * // 把当前地图范围[100, 200, 300, 400]导出为png图片
      * this.exportPng([100, 200, 300, 400]);
     */
    exportPng(bounds, options)  {
            options = options || {};
            if (Array.isArray(bounds) && bounds.length === 4 && typeof bounds[0] === 'number') {
                bounds = vjmap.GeoBounds.fromArray(bounds);
            } else {
               bounds = vjmap.GeoBounds.fromDataExtent(bounds);
            }
            bounds = bounds.scale(options.scale || 1.01); // 稍大点,要不边框线有可能刚好看不见了
            let pictureWidth = options.pictureWidth || 1024;
            let svc = this.map.getService();
            let wmsUrl = svc.wmsTileUrl({
                width: pictureWidth,
                height: Math.round(pictureWidth * bounds.height() / bounds.width()),
                srs: "",
                bbox: bounds.toString(),
                transparent: options.transparent || false,
                backgroundColor: options.backgroundColor || 'rgb(0,0,0)'
            });
            if (!options.disableOpen) {
              window.open(wmsUrl);
            }
            return wmsUrl;
        }
    

    /**
     * 手动交互式绘制一个多边形
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认true,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.extrusionHeight 拉伸高度,有拉伸高度为拉伸对象,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一个多边形
      * const polygon = await this.drawPolygon({
      * isSnap: true,
      * color: "#FF0000",
      * isFill: true,
      * opacity: 0.8
      * });
      * if (!polygon) return;
      * console.log("多边形ID:", polygon.id);
      * console.log("多边形的点坐标:", polygon.points);
     */
    async drawPolygon(options)  {
            let points = await this.actionDrawPolygon(options.isSnap);
            if (!points) return;
            return this.createPolygon(points, options);
        }
    

    /**
     * 删除绘制的图元
     * @param {string | string[]} id 图元ID或图元ID数组,参数必填
     * @example
      * // 删除绘制的全部图元
      * const geojson = this.getDrawAll();
      * if (!geojson) return;
      * let ids = [];
      * for(let i = 0; i < geojson.features.length; i++) {
      * let feature = geojson.features[i];
      * ids.push(feature.id);
      * }
      * this.deleteDrawFeature(ids);
     */
    deleteDrawFeature(id)  {
            let draw = this.map.getDrawLayer();
            draw.delete(id);
        }
    

    /**
     * 根据数据创建等值线
     * @param {Object} options 配置参数
     * @param {number[]} options.breaks 等值线分级
     * @param {string} [options.model] 插值模型,可选值为 'exponential', 'gaussian', 'spherical', 默认'exponential',
     * @param {number} [options.sigma2] 方差参数,默认0, 一般设置为 0 ,其他数值设了可能会出空白图
     * @param {number} [options.alpha] 方差函数的先验值,默认100,此参数可能控制钻孔扩散范围,越小范围越大,少量点效果明显,但点多了且分布均匀以后改变该数字即基本无效果了
     * @param {string[]} [options.colors] 等值面分级区间颜色
     * @param {number} [options.width] 生成等值线宽度参数,默认500
     * @param {number} [options.contoursSize] 等值面分级区间数,默认20,值越大,等值线越密
     * @param {[number, number, number, number]} [options.extent] 要绘制的范围,默认根据数据范围自动生成
     * @param {number} [options.maxHeight] 最大值要拉伸的高度,默认100
     * @param {[number, number]} [options.clipBounds] 裁剪范围,默认不裁剪
     * @param {boolean} [options.drawSymbols] 是否绘制原始点,默认false
     * @param {boolean} [options.drawPolyline] 是否绘制等值线,默认true
     * @param {boolean} [options.drawPolygon] 是否绘制等值面,默认false
     * @param {boolean} [options.drawFillExtrusion] 是否绘制拉伸等值面,默认false
     * @returns {Object} 返回对象,包含创建数据源Id数组和图层Id数组 {sourceIds: string[], layerIds: string[]}
     * @example
      * // 在地图的实际范围内随机生成50个点,每个点随机赋值一个10到150的随机值,根据这些点绘制等值线
      * let points = this.randomPointInMapBounds(50);
      * let data = points.map(p => ({x: p[0], y: p[1], value: Math.floor(Math.random() * 90) + 10}));
      * let contour = await this.vectorContour({data});
      * console.log(contour);
     */
    async vectorContour(options)  {
            options = options || {};
            options.data = options.data || [];
            let dataset = {
                "type" : "FeatureCollection",
                "features" : []
            };
            let dataMinValue = 0;
            let dataMaxValue = 0;
            options.data = options.data.map(item => {
                return Array.isArray(item) ? {
                    x: item[0],
                    y: item[1],
                    value: item[2]
                } : item;
            });
            let minx, miny, maxx, maxy;
            for (let i = 0; i < options.data.length; i++) {
                if (i == 0) {
                    dataMinValue = options.data[i].value;
                    dataMaxValue = options.data[i].value;
                    minx = options.data[i].x;
                    miny = options.data[i].y;
                    maxx = options.data[i].x;
                    maxy = options.data[i].y;
                } else {
                    if (options.data[i].value < dataMinValue) dataMinValue = options.data[i].value;
                    if (options.data[i].value > dataMaxValue) dataMaxValue = options.data[i].value;
                    if (options.data[i].x < minx) minx = options.data[i].x;
                    if (options.data[i].y < miny) miny = options.data[i].y;
                    if (options.data[i].x > maxx) maxx = options.data[i].x;
                    if (options.data[i].y > maxy) maxy = options.data[i].y;
                }
                let feature={
                    "type" : "Feature",
                    "properties" : {
                        "value" : options.data[i].value
                    },
                    "geometry" : {
                        "type" : "Point",
                        "coordinates" : this.map.toLngLat([options.data[i].x,options.data[i].y])
                    }
                };
                dataset.features.push(feature);
            }
            let extent = options.extent || vjmap.GeoBounds.fromArray([minx, miny, maxx, maxy]).scale(1.2).toArray();
            let contoursSize = options.contoursSize || 20; // 【值越大,等值线越密】等值面分级区间数,这里设置为20,可以自行设置
            let model = options.model || 'exponential'; // 当前模型方法名
            let alpha = options.alpha || 100; // 当前alpha值
            let colors = options.colors || ["#006837", "#1a9850", "#66bd63", "#a6d96a", "#d9ef8b", "#ffffbf","#fee08b",
                "#fdae61", "#f46d43", "#d73027", "#a50026"];
            let propField = "value";
            let maxHeight = options.maxHeight || this.map.pixelToHeight(100, this.map.getZoom()) ; // 设置最大值要拉伸的高度
            let contours = [];
            let isClipContour = false;
            if (options.clipBounds) {
                isClipContour = true;
                options.clipBounds = vjmap.GeoBounds.fromArray(options.clipBounds);
            }
    
            for(let i = 0; i < contoursSize; i++) {
                contours.push(dataMinValue + (dataMaxValue - dataMinValue) * i /  (contoursSize - 1));
            }
            if (dataMinValue >= 10 && dataMaxValue > 100) {
                // 等值线的值按10取整
                for(let i = 0; i < contours.length; i++) {
                    contours[i] = (parseInt(contours[i]/10) * 10);
                }
            }
    
            let interpolateInput = [], interpolateOutput = [];
            for(let i = 0; i < colors.length; i++) {
                interpolateInput.push(i / (colors.length - 1)); // 插值输入值,这里输入0-1之间的比例
                interpolateOutput.push(colors[i]) // 插值输出值,这里输入0-1之间的比例对应的颜色值
            }
    
            // 启动webworker计算函数
            let createContourWorker = vjmap.WorkerProxy(vjmap.vectorContour);
            let { grid, contour, variogram } =  await createContourWorker(this.map.fromLngLat(dataset), propField, contours, {
                model: model || 'exponential', // 'exponential','gaussian','spherical',三选一,默认exponential
                sigma2: options.sigma2 || 0, // sigma2是σ²,对应高斯过程的方差参数,也就是这组数据z的距离,方差参数σ²的似然性反映了高斯过程中的误差,并应手动设置。一般设置为 0 ,其他数值设了可能会出空白图
                alpha: alpha, // [如果绘制不出来,修改此值,可以把此值改小] Alpha α对应方差函数的先验值,此参数可能控制钻孔扩散范围,越小范围越大,少量点效果明显,但点多了且分布均匀以后改变该数字即基本无效果了,默认设置为100
                extent: extent, // 如果要根据数据范围自动生成此范围,则无需传此参数
                width: options.width || 500 // 生成等值线宽度参数。像素长度。默认200。宽度值越大,绘制越精确,但也会导致速度变慢,内存占用越多
            }, []);
            contour = this.map.toLngLat(contour);
           
            // 根据比例插值颜色
            const mapProgressToValues = value => vjmap.interpolate(
                interpolateInput,
                interpolateOutput,
                { ease: vjmap.linear }
            )(value)
    
            // 把原数据的颜色也设置下,绘制marker需要
            dataset.features.forEach(f => f.properties.color = mapProgressToValues((f.properties.value - dataMinValue) / (dataMaxValue - dataMinValue)))
    
            let h = maxHeight; // 设置最大值要拉伸的高度
            for(let i = 0; i < contour.features.length; i++) {
                let prop = contour.features[i].properties;
                let r = (prop.value - dataMinValue) / (dataMaxValue - dataMinValue);
                prop.color = mapProgressToValues(r); // 插值出颜色值
                prop.height = h * r; // 插值出要拉伸的高度值
            }
    
            contour.features.forEach(f => {
                f.properties.formatValue = Math.round(f.properties.value) // 多加一个用于格式化的注记的值
            })
    
            
            let markers = null;
            let markerLayerId = "marker_contour_" + vjmap.RandomID();
            const addMarkers = ()=> {
                if (markers) return;
                markers = dataset.features.map(f => {
                    if (isClipContour && !clipBounds.contains(this.map.fromLngLat(f.geometry.coordinates))) {
                        // 如果是裁剪等值线,则超出范围的marker不进行绘制
                        return null;
                    }
                    // 再随机生成不同样式的
                    let _marker = new vjmap.DiffusedApertureMarker({
                        lngLat: f.geometry.coordinates,
                        text: f.properties.value.toFixed(0)
                    }, {
                        // 可以给不同的属性,如宽度,颜色,字体
                        width: 10,
                        colors: [f.properties.color, vjmap.randomColor()],
                        textFontSize: 14,
                        textColor: f.properties.color
                    }).createMarker();
                    _marker.layerId = markerLayerId
                    _marker.addTo(this.map)
                    return _marker
                })
            }
            const removeMarkers = ()=> {
                if (!markers) return;
                for(let i = markers.length - 1; i >= 0; i--) {
                    if (markers[i]) markers[i].remove();
                }
                markers = null;
            }
    
            let symbols = null;
            const addSymbols = async ()=> {
                if (symbols) return;
                let contourData = contour;
                if (isClipContour) contourData = clipContours(contour, clipBounds);
    
                // 增加一个文字背景图片,背景色和地图背景色一样
                await this.map.addImageData("imgMaskText", `<svg viewBox="0 0 1024 1024" width="1024" height="1024" xmlns="http://www.w3.org/2000/svg">
                            <path d="M0 0L0 1024 1024 1024 1024 0z"  fill="#022B4F"></path>
                        </svg>`, 30, 15);
                symbols = new vjmap.Symbol({
                    data: contourData,
                    iconImage: "imgMaskText",
                    symbolSpacing: 250, // 符号空格,默认250像素
                    textField:  [
                        'format',
                        ["to-string", ['round', ['get', 'value']]], // 把值取整显示,如果要小数点用这个 ['number-format',['get', 'value'], { 'min-fraction-digits': 1, 'max-fraction-digits': 1 }],
                        {}
                    ],
                    textFont: ['Arial Unicode MS Regular'],
                    textSize: 14,
                    textColor: '#00ffff',
                    symbolPlacement: "line",
                    textAnchor: 'center',
                    textRotationAlignment: "this.map",
                    iconAllowOverlap: false,
                    textAllowOverlap: false
                });
                symbols.addTo(this.map);
            }
    
            const removeSymbols = ()=> {
                if (!symbols) return;
                symbols.remove();
                symbols = null;
            }
    
            let polyline = null;
            const addPolyline = ()=> {
                if (polyline) return;
                let contourData = contour;
                if (isClipContour) contourData = clipContours(contour, clipBounds);
                polyline = new vjmap.Polyline({
                    data: contourData,
                    lineColor: ['case', ['to-boolean', ['feature-state', 'hover']], '#00ffff', ['get', 'color']],
                    isHoverPointer: true,
                    isHoverFeatureState: true
                });
                polyline.addTo(this.map);
                polyline.clickPopup(f => `<h3>值: ${f.properties.value.toFixed(2)}</h3>Color: ${f.properties.color}`, { anchor: 'bottom' });
    
            }
            const removePolyline = ()=> {
                if (!polyline) return;
                polyline.remove();
                polyline = null;
                removeSymbols();
            }
            const drawPolyline = async () => {
                addPolyline();
                removeSymbols();
                await addSymbols();
            }
    
            let polygon = null;
            const addPolygon = ()=> {
                if (polygon) return;
                let contourData = contour;
                if (isClipContour) contourData = clipContoursPolygon(contour, clipBounds);
                polygon = new vjmap.Polygon({
                    data: contourData,
                    fillColor: ['case', ['to-boolean', ['feature-state', 'hover']], '#00ffff', ['get', 'color']],
                    fillOpacity: 0.9,
                    isHoverPointer: true,
                    isHoverFeatureState: true
                });
                polygon.addTo(this.map);
                polygon.clickPopup(f => `<h3>值: ${f.properties.value.toFixed(2)}</h3>Color: ${f.properties.color}`, { anchor: 'bottom' });
            }
            const removePolygon = ()=> {
                if (!polygon) return;
                polygon.remove();
                polygon = null;
                removeSymbols();
            }
    
            const drawPolygon = async () => {
                addPolygon();
                removeSymbols();
                await addSymbols();
            }
    
            let fillExtrusions = null;
            const addFillExtrusion = ()=> {
                if (fillExtrusions) return;
                fillExtrusions = new vjmap.FillExtrusion({
                    data: contour,
                    fillExtrusionColor: ['case', ['to-boolean', ['feature-state', 'hover']], '#00ffff', ['get', 'color']],
                    fillExtrusionOpacity: 0.9,
                    fillExtrusionHeight: ['get', 'height'],
                    fillExtrusionBase:0,
                    isHoverPointer: true,
                    isHoverFeatureState: true
                });
                fillExtrusions.addTo(this.map);
                fillExtrusions.clickPopup(f => `<h3>值: ${f.properties.value.toFixed(2)}</h3>Color: ${f.properties.color}`, { anchor: 'bottom' });
            }
            const removeFillExtrusion = ()=> {
                if (!fillExtrusions) return;
                fillExtrusions.remove();
                fillExtrusions = null;
                removeSymbols();
            }
    
            const drawFillExtrusion = async ()=> {
                addFillExtrusion();
                removeSymbols();
                await addSymbols();
            }
    
            let clipPolyline = null;
            const addClipPolyline = () => {
                if (clipPolyline) return;
                let points = clipBounds.toPointArray();
                points.push(points[0]);
                clipPolyline = new vjmap.Polyline({
                    data: this.map.toLngLat(points),
                    lineWidth: 2,
                    lineColor: 'red'
                });
                clipPolyline.addTo(this.map);
            }
            const removeClipPolyline = ()=> {
                if (!clipPolyline) return;
                clipPolyline.remove();
                clipPolyline = null;
            }
    
            
            // 要裁剪的多段线数组和要裁剪的范围
            const clipContours = (polylineData, clipBounds) => {
                let data = {
                    type: 'FeatureCollection',
                    features: []
                }
                for(let k = 0; k < polylineData.features.length; k++) {
                    // 遍历每一个子多边形
                    for(let n = 0; n < polylineData.features[k].geometry.coordinates.length; n++) {
                        let coordinates = this.map.fromLngLat(polylineData.features[k].geometry.coordinates[n]);
                        // 一段一段的与范围去裁剪
                        let clipCoordinates = [];
                        let clipSubCoordinates = [];
                        for(let j = 1; j < coordinates.length; j++) {
                            let p1 = vjmap.geoPoint(coordinates[j - 1]);
                            let p2 = vjmap.geoPoint(coordinates[j]);
                            let res = vjmap.clipSegment(p1, p2, clipBounds);
                            if (res === false) {
                                // 在范围外,之前的线段弄个单独一条线段,后面的重新做为一条新的线段
                                if (clipSubCoordinates.length > 0) {
                                    clipCoordinates.push(this.map.toLngLat(clipSubCoordinates));
                                    clipSubCoordinates = [];
                                }
                                continue;
                            }
                            let pt1 = [res[0].x, res[0].y];
                            let pt2 = [res[1].x, res[1].y];
                            clipSubCoordinates.push(pt1, pt2);
                        }
                        if (clipSubCoordinates.length > 0) {
                            clipCoordinates.push(this.map.toLngLat(clipSubCoordinates));
                        }
                        if (clipCoordinates.length > 0) {
                            for(let i = 0; i < clipCoordinates.length; i++) {
                                let feature = vjmap.cloneDeep(polylineData.features[k]);
                                feature.geometry.type = "LineString" ;// 由多边形改成多段线
                                feature.geometry.coordinates = clipCoordinates[i];
                                data.features.push(feature);
                            }
                        }
                    }
                }
                return data
            }
    
            // 要裁剪的多边形和要裁剪的范围
            const clipContoursPolygon = (polygonData, clipBounds) => {
                let data = {
                    type: 'FeatureCollection',
                    features: []
                }
                for (let k = 0; k < polygonData.features.length; k++) {
                    // 遍历每一个子多边形
                    for (let n = 0; n < polygonData.features[k].geometry.coordinates.length; n++) {
                        let feature = vjmap.cloneDeep(polygonData.features[k]);
                        feature.geometry.coordinates = []
                        let coordinates = this.map.fromLngLat(polygonData.features[k].geometry.coordinates[n]);
                        let clipCoordinates = vjmap.clipPolygon(coordinates, clipBounds)
                        if (clipCoordinates.length > 2) {
                            clipCoordinates.push(clipCoordinates[0]); //闭合
                            feature.geometry.coordinates.push(this.map.toLngLat(clipCoordinates));
                            feature.properties.area = vjmap.calcPolygonArea(clipCoordinates)
                            data.features.push(feature)
                        }
                    }
                }
                // 按面积大小排下序。有时候裁剪后会导致一些面积大的覆盖之前面积小的,导致小的看不见
                data.features = data.features.sort((a, b) => b.properties.area - a.properties.area)
                return data
            }
    
            if (options.drawSymbols) {
                addMarkers();
            }
            if (options.drawPolyline !== false) {
                await drawPolyline();
            }
            if (options.drawPolygon) {
                await drawPolygon();
            }
            if (options.drawFillExtrusion) {
                await drawFillExtrusion();
            }
            if (isClipContour) {
                addClipPolyline();
            }
    
            let sourceIds = [];
            let layerIds = [];
            if (markers) {
                sourceIds.push(markerLayerId);
                layerIds.push(markerLayerId);
            }
            if (symbols) {
                sourceIds.push(symbols.sourceId);
                layerIds.push(symbols.layerId);
            }
            if (polyline) {
                sourceIds.push(polyline.sourceId);
                layerIds.push(polyline.layerId);
            }
            if (polygon) {
                sourceIds.push(polygon.sourceId);
                layerIds.push(polygon.layerId);
            }
            if (fillExtrusions) {
                sourceIds.push(fillExtrusions.sourceId);
                layerIds.push(fillExtrusions.layerId);
            }
            if (clipPolyline) {
                sourceIds.push(clipPolyline.sourceId);
                layerIds.push(clipPolyline.layerId);
            }
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
               for(let i = 0; i < sourceIds.length; i++) {
                if (sourceIds[i].indexOf("marker_contour_")  == 0) {
                    // 如果是marker, 需要单独处理下
                    let markers = this.map.getMarkers();
                    // 倒序删除
                    for(let j = markers.length - 1; j >= 0; j--) {
                        if (markers[j].layerId == sourceIds[i]) {
                            markers[j].remove();
                        }
                    }
                } else {
                    this.map.removeSourceEx(sourceIds[i]);
                }
               }
            });
    
            return { sourceIds, layerIds }
        }
    

    /**
     * 创建绘制数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.entColorToHtmlColor 颜色转化为html颜色,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer10的绘制数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createDrawDataLayer(geojson, {
      * layerName: 'layer10',
      * });
      * console.log(layer);
     */
    async createDrawDataLayer(data, options)  {
            options = options || {};
            let type = "draw";
      
            if  (options.entColorToHtmlColor === undefined) {
              for(let f of data.features) {
                if (f.properties && typeof f.properties.color == "number") {
                    if (f.properties.color < 0) {
                        options.entColorToHtmlColor = true;
                        break;
                      }
                  }
              }
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createDrawDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建热力图数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {Array|number} options.heatmapWeight 热力图权重,表示点对热力图的贡献度,值越大显示越明显,参数可选,默认值为[0,1]区间
     * @param {Array|number} options.heatmapRadius 热力图点的计算半径,单位为像素,参数可选,默认值为30
     * @param {Array|string} options.heatmapColor 热力图的颜色配置,可设置不同数值的颜色表现,参数可选
     * @param {Array|number} options.heatmapIntensity 热力图整体强度,类似权重但作用于整体,参数可选,默认值随缩放级别在1-3之间
     * @param {Array|number} options.heatmapOpacity 热力图透明度,取值范围0-1,参数可选,默认值随缩放级别变化
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer16的热力图数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createHeatmapLayer(geojson, {
      * layerName: 'layer16'
      * });
      * console.log(layer);
     */
    async createHeatmapLayer(data, options)  {
            options = options || {};
            let type = "heatmap";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                // heatmapWeight:表示一个点对热力图权重的贡献,在贡献越大的地方热力图显示应该越明显
                heatmapWeight:  [
                  'interpolate',
                  ['linear'],
                  ['get', 'value'],
                  0, // 因为上面用了0,100,最小和最大值,把这两个最小和最大值归化到0,1区间
                  0,
                  100,
                  1
                ],
                // heatmapRadius:热力图的一个点计算权重的时候计算的点的半径,单位为像素,默认为30
                heatmapRadius: [
                    'interpolate',
                    ['linear'],
                    ['zoom'],
                    0, //0级别
                    10, //半径10
                    9, // 9级别 (其余级别,线性插值)
                    50 // 半径50
                ],
                // heatmapColor:热力图的颜色,设置在各个热力图的数值上是什么颜色
                heatmapColor: [
                    'interpolate',
                    ['linear'],
                    ['heatmap-density'],
                    0,
                    'rgba(33,102,172,0)',
                    0.2,
                    'rgb(103,169,207)',
                    0.4,
                    'rgb(209,229,240)',
                    0.6,
                    'rgb(253,219,199)',
                    0.8,
                    'rgb(239,138,98)',
                    1,
                    'rgb(178,24,43)'
                ],
                //heatmapIntensity:热力图强度,有点类似于heatmapWeight属性,但是该属性是设置整体上热力图的强度
                heatmapIntensity: [
                    'interpolate',
                    ['linear'],
                    ['zoom'],
                    0,
                    1,
                    9,
                    3
                ],
                //heatmapOpacity:热力图的透明度
                heatmapOpacity: [
                    'interpolate',
                    ['linear'],
                    ['zoom'],
                    7,
                    1,
                    9,
                    0
                ],
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加��层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createHeatmapLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 清除所有选择的实体对象
     * @example
      * // 清除所有选择的实体对象
      * this.clearSelectedFeatures();
     */
    clearSelectedFeatures()  {
           vjcommon.clearHighlight(this.map);
        }
    
    

    /**
     * 通过json数据创建新的地图
     * @param {array} drawJson `drawJson` 是一个 JSON 数组,其中每个元素为一个图形实体的定义对象。绘制的坐标系是标准的迪卡尔坐标系。所有实体均继承自 `DbEntity`,并根据具体的图形类型提供额外的属性。以下是支持的实体类型及其格式:
     * @param {object} options 其他参数(可选), 支持以下参数:
     * @example
      * // 示例一
      * // 创建中心点为[10,10],半径为5,颜色为红色的圆
      * let drawJson = [{
      * "typename": "DbCircle",
      * "center": [10, 10, 0],
      * "radius": 5,
      * "color": "#FF0000"
      * }]
      * // 创建一个多段线,包含两个点[10,10]和[20,20],颜色为绿色,线宽为2
      * drawJson.push({
      * "typename": "DbPolyline",
      * "points": [[10, 10], [20, 20]],
      * "color": "#00FF00",
      * "lineWidth": 2
      * })
      * // 通过上面生成的drawJson数据创建地图
      * let mapid = await this.createMapData(drawJson);
      * console.log(mapid)
      * // 示例二
      * // 基于图sys_hello/v1,选择图中的"TEXT"图层,创建一个单行文本,位置为[10108,10556],文本高2000,文本内容为"Hello, World!",水平居中对齐,垂直居中对齐, 再创建一个填充的三角形,坐标为[[10,10],[20,20],[10,20]],填充颜色为#00FF00, 图层名称为"ly1"
      * await this.createMapData([{
      * "typename": "DbText",
      * "position": [10108, 10556, 0],
      * "height": 2000,
      * "text": "Hello, World!",
      * "horizontalMode": 1,
      * "verticalMode": 2
      * }, {
      * "typename": "DbHatch",
      * "points": [[10, 10], [20, 20], [10, 20]],
      * "color": "#00FF00",
      * "layer": "ly1"
      * }], {
      * "from": "sys_hello/v1",
      * "pickLayers": ["TEXT"]
      * });
      * // 示例三
      * // 在位置[10, 10], [5000, 0], [0, 6000], 在这三个位置分别创建块参照,这三个块参照都来源于克隆图形sys_symbols,克隆实体id为25B。第二个块参照旋转45,第三个块参照放大3倍, 创建完直接加到当前地图中
      * await this.createMapData([{
      * "typename": "DbBlockReference",
      * "position": [10, 10],
      * "cloneFromDb": "sys_symbols",
      * "cloneObjectId": "25B"
      * }, {
      * "position": [5000, 0],
      * "cloneFromDb": "sys_symbols",
      * "cloneObjectId": "25B",
      * "rotateMat": 45
      * }, {
      * "position": [0, 6000],
      * "cloneFromDb": "sys_symbols",
      * "cloneObjectId": "25B",
      * "scaleMat": 3
      * }], {
      * "openway": 1
      * });
     */
    async createMapData(drawJson, options)  {
            return await this.context.tools.createMapData(this.context, drawJson, options)
        }
    

    /**
     * 删除一个信息窗口Popup
     * @param {string} id 信息窗口Popup的id
     * @example
      * this.deletePopup("popup_1"); // 删除id为Popup_1的信息窗口
     */
    deletePopup(id)  {
           let popups = this.context.global.popups || [];
           let item = popups.find(m => m.id == id);
           if (item) {
            item.popup.remove()
            let pt = this.map.fromLngLat(item.popup.getLngLat());
             // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.addPopup(pt, item.options);
            });
           }
          
        }
    

    /**
     * 创建旋转的光环数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer23的旋转的光环数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createRotatingMarkerLayer(geojson, {
      * layerName: 'layer23'
      * });
      * console.log(layer);
     */
    async createRotatingMarkerLayer(data, options)  {
            options = options || {};
            let type = "rotatingMarker";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                width: 80,
                markerHeight: 80,
                color1: "#ff0000",
                color2: "#ffff00",
                textFontSize: 15,
                textColor: "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createRotatingMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 增加一个功能菜单及实现功能
     * @param {string} name 菜单名
     * @param {Function} func 要实现的功能函数
     * @example
      * // 增加一个功能菜单,菜单名为全图显示,功能为将地图缩放至全图显示
      * this.addMenuItem("全图显示", () => {
      * //缩放至全图显示
      * this.fitMapBounds();
      * })
     */
    addMenuItem(name, func)  {
           // 默认情况下增加的功能菜单,地图右键菜单中进行显示
           this.context.ui.addMenuItem(name, func);   
           // 添加撤销记录
           this.context.ui.addUndoRecord(() => {
                this.removeMenuItem(name);
            });
        }
    

    /**
     * 手动交互式绘制一个椭圆或椭圆弧
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {string} options.borderColor 边框颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.arc 是否绘制椭圆弧,默认false,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.width 线宽,默认1,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.borderOpacity 边框透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 手动绘制一个填充椭圆,启用捕捉,颜色为红色,透明度0.6,线宽2,边框颜色为黄色,透明度0.8
      * const ellipseFill = await this.drawEllipse({
      * isSnap: true,
      * color: "#FF0000",
      * isFill: true,
      * opacity: 0.6,
      * width: 2,
      * borderColor: "#FFFF00",
      * borderOpacity: 0.8
      * });
      * if (ellipseFill && ellipseFill.id) {
      * console.log("椭圆ID:", ellipseFill.id);
      * }
      * // 示例二
      * // 手动绘制一个椭圆,颜色为红色,线宽3
      * const ellipse = await this.drawEllipse({
      * color: "#FF0000",
      * isFill: false,
      * width: 3,
      * });
      * if (ellipse && ellipse.id) {
      * console.log("椭圆ID:", ellipse.id);
      * }
      * // 示例三
      * // 手动绘制一个椭圆弧,颜色为黄色,线宽2
      * const ellipseArc = await this.drawEllipse({
      * color: "#FFFF00",
      * isFill: false,
      * arc: true,
      * width: 2,
      * });
      * if (ellipseArc && ellipseArc.id) {
      * console.log("椭圆弧ID:", ellipseArc.id);
      * }
     */
    async drawEllipse(options)  {
            options = options || {};
            let draw = this.map.getDrawLayer();
            let snapObj = {};
            if (options.isSnap) {
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawOptions = options.isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {};
            let featureId; 
            if (options.isFill) {
                if (options.arc) {
                    featureId = await vjcommon.drawEllipseFillArc(this.map, draw, drawOptions, {
                        "color": options.color,// 颜色
                        "opacity": options.opacity, // 透明度
                        "outlineColor": options.borderColor || options.color,// 边框颜色
                        "line_width": options.width, // 线宽
                        "line_opacity": options.borderOpacity, // 透明度
                        "data": options.data
                    }, () => this.map.logInfo);
                } else {
                    featureId = await vjcommon.drawEllipseFill(this.map, draw, drawOptions, {
                        "color": options.color,// 颜色
                        "opacity": options.opacity, // 透明度
                        "outlineColor": options.borderColor || options.color,// 边框颜色
                        "line_width": options.width, // 线宽
                        "line_opacity": options.borderOpacity, // 透明度
                        "data": options.data
                    }, () => this.map.logInfo);
                }
            } else {
                if (options.arc) {
                    featureId = await vjcommon.drawEllipseArc(this.map, draw, drawOptions, {
                        "color": options.borderColor || options.color,// 颜色
                        "line_width": options.width, // 线宽
                        "data": options.data
                    }, () => this.map.logInfo);
                } else {
                    featureId = await vjcommon.drawEllipseEdge(this.map, draw, drawOptions, {
                        "color": options.borderColor || options.color,// 颜色
                        "line_width": options.width, // 线宽
                        "data": options.data
                    }, () => this.map.logInfo);
                }
            }
            if (featureId) {
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.map.getDrawLayer().delete(featureId);
                });
                return { id: featureId };
            }
        }
    

    /**
     * 创建点标记数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {string} options.color 标记颜色,参数可选,默认为'#3FB1CE'
     * @param {number[]} options.offset 偏离XY像素值,如[0,0],负数表示向左和向上
     * @param {number} options.rotation 标记旋转角度,顺时针旋转,默认0
     * @param {string} options.anchor 标记锚点位置,可选值:center、top、bottom、left、right、top-left、top-right、bottom-left、bottom-right,默认center
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型:MAP_ANIMATION_NONE(无动画)、MAP_ANIMATION_BOUNCE(弹跳)、MAP_ANIMATION_DROP(坠落)
     * @param {string} options.rotationAlignment 旋转对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {string} options.pitchAlignment 倾斜对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {number} options.scale 缩放比例,默认1,对应高度41px宽度27px
     * @param {number} options.scaleMaxZoom 能缩放的最大级别(0-24),小于此级别时自动缩放
     * @param {number} options.height 标高值,单位CAD图制图单位
     * @param {boolean} options.removeWhenNoInMapView 是否在视图范围内自动显隐
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐的padding像素值,默认500
     * @param {number} options.clickTolerance 点击像素容差,默认继承地图的clickTolerance
     * @param {string} options.customImage 自定义图片地址/base64/svg内容
     * @param {number} options.customImageWidth 自定义图片宽度
     * @param {number} options.customImageHeight 自定义图片高度
     * @param {string} options.customHtml 自定义Html元素的JS代码
     * @param {string} options.popupHtml 信息窗口HTML内容
     * @param {[number,number]} options.popupOffset 信息窗口偏离XY像素值
     * @param {string} options.popupAnchor 信息窗口锚点位置,同anchor参数
     * @param {boolean} options.closeButton 是否显示关闭按钮
     * @param {boolean} options.closeOnClick 是否在点击地图时关闭弹出窗口
     * @param {boolean} options.closeOnMove 是否在地图移动后关闭信息窗口
     * @param {boolean} options.focusAfterOpen 是否尝试聚焦弹出窗口内第一个可聚焦元素
     * @param {string} options.className 添加到弹出容器的CSS类名
     * @param {string} options.maxWidth 弹出窗口最大宽度,CSS属性字符串,默认'240px'
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer19的点标记数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createMarkerDataLayer(geojson, {
      * layerName: 'layer19'
      * });
      * console.log(layer);
     */
    async createMarkerDataLayer(data, options)  {
            options = options || {};
            let type = "marker";
        
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                color: '#3FB1CE',
                closeButton: true,
                closeOnClick: true,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createMarkerDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 取消监听地图事件
     * @param {string} eventName 事件名称,参数必填, 事件名称有:
     * @param {function | undefined} callback 事件回调函数,可为空,为空时取消所有事件,默认undefined
     * @example
      * // 取消监听地图单击事件
      * this.cancelListenMapEvent("click");
     */
    cancelListenMapEvent(eventName, callback)  {
            if (eventName === "clickEntity") {
                this.map.disableLayerClickHighlight();
                if (this.context.global._delegatedListeners) delete this.context.global._delegatedListeners[eventName];
                return;
            }
            if (callback) {
                this.map.off(eventName, callback);
    
                if (this.context.global._delegatedListeners && this.context.global._delegatedListeners[eventName]) {
                    let index = this.context.global._delegatedListeners[eventName].indexOf(callback);
                    if (index !== -1) {
                        this.context.global._delegatedListeners[eventName].splice(index, 1);
                    }
                }
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.map.on(eventName, callback);
    
                    this.context.global._delegatedListeners = this.context.global._delegatedListeners || {};
                    this.context.global._delegatedListeners[eventName] = this.context.global._delegatedListeners[eventName] || [];
                    this.context.global._delegatedListeners[eventName].push(callback);
                });
            } else {
                if (!this.context.global._delegatedListeners) return;
                if (!this.context.global._delegatedListeners[eventName]) return;
                const listener = this.context.global._delegatedListeners[eventName];
                if (listener) {
                    let saveListener = [...listener]; 
                    listener.forEach(func => {
                        this.map.off(eventName, func);
    
                        if (this.context.global._delegatedListeners && this.context.global._delegatedListeners[eventName]) {
                            let index = this.context.global._delegatedListeners[eventName].indexOf(func);
                            if (index !== -1) {
                                this.context.global._delegatedListeners[eventName].splice(index, 1);
                            }
                        }
                    });
                    // 添加撤销记录
                    this.context.ui.addUndoRecord(() => {
                        saveListener.forEach(func => {
                            this.map.on(eventName, func);
                            
                            this.context.global._delegatedListeners = this.context.global._delegatedListeners || {};
                            this.context.global._delegatedListeners[eventName] = this.context.global._delegatedListeners[eventName] || [];
                            this.context.global._delegatedListeners[eventName].push(func);
                        });
                    });
                }
            }
            
        }
    

    /**
     * 获取WMS瓦片URL
     * @param {object} options WMS配置选项
     * @param {string} [options.mapid] 地图ID
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {string} [options.layer] 图层样式名称(如果为空时,则用默认样式)
     * @param {string} [options.epsg] cad图epsg代号
     * @param {"beijing54"|"xian80"|"cgs2000"} [options.crs] cad图的坐标系,beijing54(北京54坐标)、xian80(西安80坐标、cgs2000(CGCS2000坐标)
     * @param {string} [options.webMapTiles] 叠加地图为互联网地图时,数据瓦片地址, 可为空
     * @param {boolean} [options.overMapImage] 叠加地图为互联网地图时,是否为影像地图
     * @param {boolean} [options.isSetRotateZero] 公共点叠加时是否允许旋转
     * @param {boolean} [options.baseMapWgs84] 底图是否为互联网地图wgs84坐标
     * @returns {Promise<string[]>} 返回wms瓦片URL数组
     * @example
      * // 叠加的地图mapid为sys_hello, 获取WMS瓦片URL, 根据此瓦片地址, 创建栅格瓦片图层
      * let wmsTileUrl = await this.getWmsTileUrl({
      * mapid: "sys_hello"
      * });
      * let layer = await this.createRasterLayer({
      * tiles: wmsTileUrl,
      * });
      * console.log(layer);
     */
    async getWmsTileUrl(options)  {
            options = options || {}
            let svc = this.map.getService();
            // 判断底图是否为互联网地图
            let isWebMap = this.map.getMapProjection() instanceof vjmap.LnglatProjection;
            let baseMapType = "CAD"
            if (isWebMap) {
                if (options.baseMapWgs84 === undefined) {
                    // 自动获取下
                    baseMapType = "GCJ02";
                    let sources = this.map.getStyle().sources;
                    for (let name in sources) {
                        let source = sources[name];
                        if (source.type === 'raster') {
                            let tiles = source.tiles;
                            if (tiles && tiles.length > 0) {
                                let tile = tiles[0];
                                if (tile.includes('tianditu') || tile.includes('openstreetmap')) {
                                    baseMapType = "WGS84";
                                    break;
                                }
                            }
                        }
                    }
                } else {
                    baseMapType = options.baseMapWgs84 === true ? "WGS84" : "GCJ02";
                }
               
            }
            let mapParam  = svc.currentMapParam() || {}
            let baseMapParam = {
                // 底图类型 
                baseMapType: baseMapType,
                // 地图ID
                mapid: mapParam.mapid,
                // 地图版本
                version: mapParam.version,
                // 地图范围
                mapbounds: JSON.stringify(this.map.getGeoBounds(1.0).toArray())
            }
    
            let overlayType = options.overlayType;
            if (overlayType !== "param") {
                if (options.epsg !== undefined) {
                    overlayType = "auto";
                } else {
                    let epsg = await this.getCadEpsgCode(options);
                    if (epsg) {
                        options.epsg = epsg;
                        overlayType = "auto";
                    }
                }
            }
           
            if (overlayType === undefined && options.coordinates !== undefined) {
                overlayType = "param";
            }
    
            let overMapType = options.overMapType || "CAD";
            
            if (options.webMapTiles === undefined) {
                let isImageUrl =  options.overMapImage === true; // 是否为影像地图
                if (overMapType === "WGS84") {
                    options.webMapTiles = vjcommon.tiandituProviderTiles(isImageUrl);
                } else if (overMapType === "GCJ02") {
                    options.webMapTiles = vjcommon.gaodeProviderTiles(isImageUrl);
                }
            }
            if (overlayType === "auto" && !options.epsg) {
                this.showMessage("请设置CAD图的epsg参数"); 
                return;
            }
            let overMapParam = {
                // 地图ID(为空时采用当前打开的mapid)
                mapid: options.mapid,
                // 地图版本(为空时采用当前打开的地图版本)
                version: options.version ,
                // 图层样式名称
                layer: options.layer,
                // cad图的坐标系
                crs: options.epsg,
                // 叠加类型
                baseMapType: overMapType,
                // 底图为互联网地图时,数据瓦片地址
                webMapTiles: Array.isArray(options.webMapTiles) ? options.webMapTiles : [options.webMapTiles]  ,
                isSetRotateZero: options.isSetRotateZero, // 公共点叠加时是否允许旋转
                coordinates: options.coordinates // 公共点坐标 x1,y1底图坐标, x2,y2对应点坐标
            };
           
            return await vjcommon.getWmsTileUrl(svc, baseMapParam, overlayType || "direct", {maps: overMapParam})
        }
    

    /**
     * 切换至矢量瓦片样式
     * @example
      * // 切换至矢量瓦片样式
      * this.switchRasterToVectorStyle();
     */
    switchRasterToVectorStyle()  {
            // 如果当前地图已经使用矢量瓦片样式,则不进行切换
            if (this.map.hasVectorLayer()) {
                return
            }
            this.map.switchRasterToVectorStyle(this.map.getService().vectorTileUrl());
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.switchVectorToRasterStyle(this.map.getService().rasterTileUrl());
            });
        }
    
    

    /**
     * 移除一个功能按钮
     * @param {string} name 按钮名
     * @example
      * // 移除按钮名为"放大一级"的功能按钮
      * this.removeButtonItem("放大一级")
     */
    removeButtonItem(name, func)  {
             this.context.ui.removeButtonItem(name, func);   
             // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.addButtonItem(name, func);
            });
          }
    

    /**
     * 采集一个点坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<[number,number] | undefined>} 返回采集的坐标[x,y],如果取消操作则返回undefined
     * @example
      * const pt = await this.actionDrawPoint(true); // 启用捕捉功能采集一个点坐标
      * if (!pt) return;
      * // 点的坐标
      * const x = pt[0];
      * const y = pt[1];
      * console.log(x, y);
     */
    async actionDrawPoint(isSnap)  {
            this.context.tools.logInfo("请在地图上绘制一个点")
            let snapObj = {};
            if (isSnap) {
                // 捕捉dwg图上的点
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawPoint = await vjmap.Draw.actionDrawPoint(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawPoint.cancel) {
                return; // 取消操作
            }
            let co = drawPoint.features[0].geometry.coordinates;
            co = this.map.fromLngLat(co);
            return [co.x, co.y];
        }
    

    /**
     * 设置数据图层属性
     * @param {string} layerName 图层名称,参数必填
     * @param {object} property 图层属性对象,参数必填
     * @example
      * // 设置图层名称为layer1的数据图层属性为{"minZoom":1,"maxZoom":5}
      * let layerName = 'layer1';
      * let property = {"minZoom":1,"maxZoom":5};
      * this.setDataLayerProperty(layerName, property);
     */
    setDataLayerProperty(layerName, property)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item) {
               let oldProp = {...vjcommon.toMapLayer(item.layer, item.layer.mapLayer)};
               let layerId = item.layerId;
               if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
               }
               item.layer.setLayerStyle(this.map, layerId, property, oldProp);
               // 添加撤销记录
               this.context.ui.addUndoRecord(() => {
                   this.setDataLayerProperty(item.layerName, oldProp);
               });
            }
        }
    

    /**
     * 测量坐标
     * @example
      * // 测量坐标
      * await this.measureCoordinate();
     */
    measureCoordinate()  {
                vjcommon.runMeasureCmd(this.map, "measureCoordinate");
            }
    
    

    /**
     * 选择地图, 返回选择的地图mapid和version
     * @returns {Object | undefined} 返回对象,包含地图id和版本 {mapid: string, version: string}, 如果取消则返回undefined
     * @example
      * // 选择地图, 返回选择的地图mapid和version
      * let res = await this.selectCadMap();
      * if (res) {
      * this.chatLog("选择的地图mapid为" + res.mapid + ", version为" + res.version);
      * }
     */
    async selectCadMap()  {
            let res = await this.context.ui.selectCadMap()
            if (!res) return;
            return {
                mapid: res.mapid,
                version: res.version
            };
        }
    
    

    /**
     * 采集一个圆的坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<Object | undefined>} 返回圆心坐标和半径,如果取消操作则返回undefined, 返回的对象包含以下属性:
     * @example
      * const circle = await this.actionDrawCircle();
      * if (!circle) return;
      * // 圆心坐标
      * const centerX = circle.center[0];
      * const centerY = circle.center[1];
      * // 半径
      * const radius = circle.radius;
      * console.log(centerX, centerY, radius);
     */
    async actionDrawCircle(isSnap)  {
            this.context.tools.logInfo("请在地图上绘制一个圆")
            let snapObj = {};
            if (isSnap) {
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawCircle = await vjmap.Draw.actionDrawCircle(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawCircle.cancel) {
                return;
            }
            let center = this.map.fromLngLat(drawCircle.features[0].properties.center);
            let circlePoint = this.map.fromLngLat(drawCircle.features[0].geometry.coordinates[0][0]);
            let radius = center.distanceTo(circlePoint);
            return {
                center: [center.x, center.y],
                radius
            };
        }
    

    /**
     * 通过前缀从服务端获取用户自定义数据的键值
     * @param {string} prefix 键名前缀
     * @returns {Promise<string[]>} 返回获取到的键值数组
     * @example
      * // 从服务端通过前缀获取用户自定义数据的键值,前缀为test
      * let keys = await this.getCustomDataKeysByPrefixServer("test");
      * console.log(keys);
     */
    async getCustomDataKeysByPrefixServer(prefix)  {
            let svc = this.map.getService();
            let res = await svc.getCustomDataKeysByPrefix(prefix);
            return res?.keys || [];
        }
    

    /**
     * 保存临时数据
     * @param {string} name 数据名
     * @param {any} data 数据内容
     * @example
      * // 将"123"保存到临时数据test中
      * this.saveTempData("test", "123");
     */
    saveTempData(name, data)  {
            this.context.resultData[name] = data
        }
    

    /**
     * 创建动画线数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.lineColor 线条颜色
     * @param {number} options.lineWidth 线条宽度
     * @param {number} options.lineOpacity 线条透明度,取值范围0-1
     * @param {number} options.lineGapWidth 线条间隙宽度,在线的实际路径之外绘制描边时的内部间隙宽度,单位像素,默认值1
     * @param {number} options.lineOffset 线的偏移量。线性要素正值向右偏移,负值向左偏移;多边形正值向内偏移,负值向外偏移,单位像素
     * @param {number} options.lineBlur 线条模糊度,配合宽度使用,该值应小于线宽度
     * @param {[number,number]} options.lineDasharray 虚线样式,数组格式如[1,1]表示实线、虚线的组合
     * @param {[number,number]} options.lineTranslate 几何体的平移量[x,y],负数分别表示左和上,单位像素,默认[0,0]
     * @param {string} options.lineCap 线帽形状,可选值:"butt"(尖头)、"round"(圆头)、"square"(平头)
     * @param {string} options.lineJoin 拐角形状,可选值:"bevel"(平拐)、"round"(圆拐)、"miter"(棱拐)
     * @param {string} options.linePattern 线的拉伸图片类型,必须与地图已加载的图片名称对应,图像宽度必须是2的系数(2、4、8、...、512)
     * @param {string} options.lineGradient 线条渐变
     * @param {string} options.animateImagesType 动画类型,可选值:"arrow"(箭头动画), "antpath"(蚂蚁线动画), "customImage"(自定义图片), "imageSprites"(同一个图片精灵动画集)
     * @param {string} options.animateImages_arrowFillColor 箭头填充颜色,当animateImagesType为"arrow"时有效,默认"#22B14C"
     * @param {string} options.animateImages_arrowStrokeColor 箭头边框颜色,当animateImagesType为"arrow"时有效,默认"#fff"
     * @param {number} options.animateImages_arrowStrokeWidth 箭头线宽,当animateImagesType为"arrow"时有效
     * @param {number} options.animateImages_arrowWidth 箭头大小,当animateImagesType为"arrow"时有效
     * @param {string} options.animateImages_fillColor1 蚂蚁线填充颜色1,当animateImagesType为"antpath"时有效
     * @param {string} options.animateImages_fillColor2 蚂蚁线填充颜色2,当animateImagesType为"antpath"时有效
     * @param {string} options.customImageUrl 自定义图片URL或base64,当animateImagesType为"customImage"时有效
     * @param {string} options.imageSpriteUrl 图片动画集URL或base64,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteWidth 来源图片中精灵图所占宽度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteHeight 来源图片中精灵图所占高度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_canvasWidth 画布宽度,所有动画类型通用
     * @param {number} options.animateImages_canvasHeight 画布高度,所有动画类型通用
     * @param {number} options.animateImages_frameCount 动画帧数,所有动画类型通用
     * @param {boolean} options.animateImages_directionReverse 动画方向是否反向,所有动画类型通用
     * @param {number} options.speed 动画速度,步长0.1
     * @param {boolean} options.startAutoAnimation 是否开始时自动播放动画
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer3的动画线数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createAnimateLineLayer(geojson, {
      * layerName: 'layer3'
      * });
      * console.log(layer);
     */
    async createAnimateLineLayer(data, options)  {
            options = options || {};
            let type = "animateLine";
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                lineColor: '#ff0000',
                lineWidth: 10,
                animateImagesType: "arrow",
                animateImages_arrowFillColor: "#22B14C",
                animateImages_arrowStrokeColor: "#fff",
                animateImages_arrowStrokeWidth: 6,
                animateImages_canvasWidth: 128,
                animateImages_canvasHeight: 32,
                animateImages_arrowWidth: 16,
                animateImages_frameCount: 4,
                animateImages_fillColor1: "#f0fb",
                animateImages_fillColor2: "#0ffb",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createAnimateLineLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建符号圆数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {number} options.circleRadius 圆半径,单位像素,参数可选
     * @param {string} options.circleColor 圆填充颜色,支持十六进制颜色值,参数可选
     * @param {number} options.circleOpacity 圆填充透明度,取值范围0-1,参数可选
     * @param {string} options.circleStrokeColor 圆边框颜色,支持十六进制颜色值,参数可选
     * @param {number} options.circleStrokeWidth 圆边框宽度,单位像素,参数可选
     * @param {number} options.circleStrokeOpacity 圆边框透明度,取值范围0-1,参数可选
     * @param {number} options.circleBlur 圆模糊度,参数可选
     * @param {[number]} options.circleTranslate 平移量,格式[x,y],负数表示向左和向上平移,单位像素,默认[0,0],参数可选
     * @param {string} options.circleTranslateAnchor 平移参考系,'map'表示相对地图平移,'viewport'表示相对视窗平移,参数可选
     * @param {string} options.circlePitchScale 倾斜时缩放对齐方式,'map'相对地图,'viewport'相对视窗,参数可选
     * @param {string} options.circlePitchAlignment 倾斜时对齐方式,'map'相对地图,'viewport'相对视窗,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer7的圆数据图层,圆半径为5,颜色为红色
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createSymbolCircleLayer(geojson, {
      * layerName: 'layer7',
      * circleRadius: 5,
      * circleColor: "#ff0000"
      * });
      * console.log(layer);
     */
    async createSymbolCircleLayer(data, options)  {
            options = options || {};
            let type = "circle";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                "circleRadius": 5,
                "circleColor": "#ffff00",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createSymbolCircleLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 选择绘制的图元
     * @param {boolean} selectSingle 是否只能选择一个图元
     * @returns {Promise<GeoJSON | undefined>} 返回选中的GeoJSON对象,如果取消操作则返回undefined
     * @example
      * const geojson = await this.actionSelect(true);
      * if (!geojson) return;
      * // 遍历geojson的每个feature
      * for(let i = 0; i < geojson.features.length; i++) {
      * let feature = geojson.features[i];
      * console.log(feature);
      * }
     */
    async actionSelect(selectSingle)  {
            this.context.tools.logInfo("请选择绘制的图元")
            let draw = this.map.getDrawLayer();
            let selection = await vjmap.Draw.actionSelect(this.map, draw, {
                selectSingle
            });
            if (selection.cancel) {
                return;
            }
            return this.map.fromLngLat(selection);
        }
    

    /**
     * 获取用户数据
     * @returns {Object} 返回GeoJson的FeatureCollection对象,包括点、线、面、多点、多线、多面类型
     * @example
      * // 获取用户数据,将数据输出至会话窗口
      * let data = this.getUserData();
      * if (data) this.chatLog(JSON.stringify(data, null, 4));
     */
    getUserData()  {
            return this.context.userData;
        }
    
    

    /**
     * 增加地图比例尺控件
     * @param {number} options.maxWidth 比例尺最大宽度,参数可选
     * @param {string} options.unit 比例尺单位,参数可选
     * @param {'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} options.position 控件位置,参数可选, 默认'bottom-left'
     * @example
      * // 增加地图比例尺控件,位置右下角
      * this.addMapScaleControl({ position: 'bottom-right' });
     */
    addMapScaleControl(options)  {
            options = options || {};
            this.context.global.controls = this.context.global.controls || {};
            if (this.context.global.controls.scaleControl) {
                this.map.removeControl(this.context.global.controls.scaleControl.control);
            }
            let scaleControl = new vjmap.ScaleControl(options);
            this.map.addControl(scaleControl, options.position || 'bottom-left');
            this.context.global.controls.scaleControl = {
                control: scaleControl,
                position: options.position,
                options: options
            };
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.removeControl(scaleControl);
                delete this.context.global.controls.scaleControl;
            }); 
        }
    

    /**
     * 设置CAD图实体对象的隐藏或显示
     * @param {Array<string>} objectids 实体id数组
     * @param {boolean} visible 是否可见, true表示可见,false表示不可见
     */
    async setCadEntityVisible(objectids, visible)  {
          if (!this.context.global.updateMapStyleObj) {
            this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
          }
          const updateMapStyleObj = this.context.global.updateMapStyleObj;
          if (visible) {
            await updateMapStyleObj.removeHideObjectIds(new Set(objectids));
          } else {
            await updateMapStyleObj.addHideObjectIds(new Set(objectids));
          }
          // 添加撤销记录
          this.context.ui.addUndoRecord(async () => {
              if (!visible) {
                await updateMapStyleObj.removeHideObjectIds(new Set(objectids));
              } else {
                await updateMapStyleObj.addHideObjectIds(new Set(objectids));
              }
          });
        }
    

    /**
     * 创建发光的光环数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer15的发光的光环数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createHaloRingMarkerLayer(geojson, {
      * layerName: 'layer15'
      * });
      * console.log(layer);
     */
    async createHaloRingMarkerLayer(data, options)  {
            options = options || {};
            let type = "haloRingMarker";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                width: 40,
                markerHeight: 40,
                color1: "#ff0000",
                color2: "#ffff00",
                textFontSize: 15,
                textColor: "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createHaloRingMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 导出为新的CAD图形
     */
    async exportCAD()  {
            this.map.logInfo("正在导出dwg并打开,请稍候...")
            const res = await vjcommon.exportDwg(this.map, this.map.getDrawLayer());
            if (res.error) {
                this.map.logInfo(res.error, "error");
                return;
            }
            const isCloud = this.map.getService().serverUrl.indexOf("vjmap.com") >= 0;
            const host = isCloud ? "https://vjmap.com/app/cloud" : (window.location.origin + "/_cloud");
            const url = host + `/#/this.map/${res.mapid}?mapopenway=Memory&version=${res.version}`;
            window.open(url);
          }
    
    

    /**
     * 增加一个功能按钮及实现功能
     * @param {string} name 按钮名,必填
     * @param {Function} func 要实现的功能函数,必填
     * @param {string} tooltip 按钮的提示信息, 参数可选
     * @example
      * // 增加一个功能按钮,按钮名为"放大一级",功能为将地图缩放级别放大一级
      * this.addButtonItem("放大一级", () => {
      * let zoom = map.getZoom();
      * map.setZoom(zoom + 1);
      * })
     */
    addButtonItem(name, func, tooltip)  {
            this.context.ui.addButtonItem(name, func, tooltip);   
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                 this.removeButtonItem(name);
             });
         }
    

    /**
     * 从服务端获取用户自定义数据
     * @param {string | string[]} key 键名,如果是数组的话,可以查询.
     * @param {object} options 选项 retDataType为空时查询数据及属性,"value"只查询数据,"prop"只查询属性。contentType返回类型,为空时为json,为"image"时为图片.
     * @returns {Promise<object>} 返回获取到的用户自定义数据,格式如下 {data: any, prop: any, status: string}
     * @example
      * // 从服务端获取键名为testKey的用户自定义数据
      * let data = await this.getCustomDataServer("testKey");
      * console.log(data);
      * // 从服务端批量获取用户自定义数据,键名为testKey1,testKey2
      * let dataArray = await this.getCustomDataServer(["testKey1", "testKey2"]);
      * console.log(dataArray);
     */
    async getCustomDataServer(key, options)  {
            let svc = this.map.getService();
            return await svc.getCustomData(key, options);
        }
    

    /**
     * 设置地图的旋转角度
     * @param {number} bearing 要设置的旋转角度
     * @example
      * this.setBearing(45); // 设置旋转角度为45度
     */
    setBearing(bearing)  {
            let oldBearing = this.map.getBearing(); // 获取当前旋转角度
            this.map.setBearing(bearing); // 设置新的旋转角度
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.setBearing(oldBearing);
            });
        }
    

    /**
     * 根据给定的点坐标数组直接绘制一个多边形
     * @param {[number, number][]} points 多边形的坐标点数组[[x1,y1],[x2,y2],...],参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认true,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.extrusionHeight 拉伸高度,有拉伸高度为拉伸对象,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Object} 返回绘制的图元对象,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 根据三个地图范围内随机点创建一个多边形
      * let points = this.randomPointInMapBounds(3); // 每个多边形3个点
      * points.push(points[0]); // 闭合多边形
      * const polygon = this.createPolygon(points, {
      * color: vjmap.randomColor(),
      * isFill: true,
      * opacity: 0.5
      * });
      * console.log(`多边形 ID:`, polygon.id);
      * console.log(`多边形 点坐标:`, polygon.points);
      * // 示例二
      * // 根据三个地图范围内随机点创建一个多边形,拉伸高度为地图范围宽度的五分之一
      * let points2 = this.randomPointInMapBounds(3); // 每个多边形3个点
      * points2.push(points2[0]); // 闭合多边形
      * const polygon2 = this.createPolygon(points2, {
      * color: vjmap.randomColor(),
      * isFill: true,
      * extrusionHeight: map.getGeoBounds().width() / 5
      * });
      * console.log(`拉伸多边形 ID:`, polygon2.id);
      * console.log(`拉伸多边形 点坐标:`, polygon2.points);
     */
    createPolygon(points, options)  {
            let draw = this.map.getDrawLayer();
            let id = vjmap.RandomID(10);
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: options.isFill !== false ? 'Polygon' : 'LineString',
                    coordinates: options.isFill !== false ? [points.map(pt => this.map.toLngLat(pt))] : points.map(pt => this.map.toLngLat(pt))
                },
                properties: {
                    color: options.color,
                    opacity: options.opacity,
                    data: options.data,
                    extrusionHeight: options.extrusionHeight ? this.map.geoLengthToHeight(options.extrusionHeight) : undefined
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                points
            };
        }
    

    /**
     * 复制CAD图实体对象
     * @param {boolean} rectSelect 是否矩形选择, false表示点选,true表示矩形选择, 参数可选, 默认false
     * @example
      * // 示例一
      * // 通过点选复制CAD图实体对象
      * await this.copyCadEntity(false);
      * // 示例二
      * // 通过矩形选择复制CAD图实体对象
      * await this.copyCadEntity(true);
     */
    async copyCadEntity(rectSelect)  {
            let draw = this.map.getDrawLayer();
            if (!this.context.global.updateMapStyleObj) {
                this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
            }
            const updateMapStyleObj = this.context.global.updateMapStyleObj;
            // 保存旧的数据,用于撤销记录
            let features = draw.getAll().features;
            let oldFeatureLength = features ? features.length : 0;
    
            await vjcommon.copyCadEntity(this.map, draw, updateMapStyleObj,  this.map.logInfo.bind(this.map), async (content) => {
                return await this.context.ui.confirm(content, "提示", "warning");
              }, rectSelect, (content) => {
                return this.context.ui.prompt("请输入内容", "提示", content);
              });
    
           
            let addFeatureIds = [];
            let newFeatures = draw.getAll().features;
            let newFeatureLength = newFeatures ? newFeatures.length : 0;
            for (let i = oldFeatureLength; i < newFeatureLength; i++) {
                addFeatureIds.push(newFeatures[i].id);
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(async () => {
                this.map.getDrawLayer().delete(addFeatureIds);
            });
        }
    

    /**
     * 创建呼吸的光圈点数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer6的呼吸的光圈点数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createBreathingMarkerLayer(geojson, {
      * layerName: 'layer6',
      * text: '索引:${props.index}'
      * });
      * console.log(layer);
     */
    async createBreathingMarkerLayer(data, options)  {
            options = options || {};
            let type = "breathingMarker";
        
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                "width": 80,
                "markerHeight": 80,
                "color1": "#ff0000",
                "color2": "#ffff00",
                "textFontSize": 15,
                "textColor": "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createBreathingMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 切换至互联网地图做为底图
     * @param {number} webmaptype 地图类型:1: 高德地图、2: 高德地图影像、3: 天地图、4: 天地图影像,可选,默认1
     * @returns {Promise<Object>} 返回参数,返回内容如下
     * @example
      * // 示例一
      * // 切换至高德地图做为底图
      * let result = await this.switchWebMap(1);
      * console.log("result", result);
      * // 示例二
      * // 切换至天地图影像做为底图
      * let result2 = await this.switchWebMap(4);
      * console.log("result2", result2);
     */
    switchWebMap(webmaptype)  {
            if (!webmaptype) webmaptype = 1;
            this.clearMapData({clearAllData: true}); 
            let prj = new vjmap.LnglatProjection();
            let webMapTiles = [];
            if (webmaptype == 1 || webmaptype == 2) {
                webMapTiles = vjcommon.gaodeProviderTiles(webmaptype == 2);
            } else if (webmaptype == 3 || webmaptype == 4) {
                webMapTiles = vjcommon.tiandituProviderTiles(webmaptype == 4);
            }
            let tiles = webMapTiles.map(t => vjcommon.getShardsTileUrl(t, this.map))
            let sourceIds = [];
            let layerIds = [];
            for(let t of tiles) {
                let id = vjmap.RandomID();
                let sourceId = "web_source_" + webmaptype + "_" + id;
                let layerId = "web_layer_" + webmaptype + "_" + id;
                this.map.addRasterSource(sourceId, {
                    type: "raster",
                    tiles: t,
                    tileSize: 256
                });
                this.map.addRasterLayer(layerId, sourceId);
                this.map.setMapProjection(prj);
                sourceIds.push(sourceId);
                layerIds.push(layerId);
            }
            
            return {
                sourceIds: sourceIds,
                layerIds: layerIds
            }
          }
    

    /**
     * 采集一条线的坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<number[][] | undefined>} 返回坐标点数组[[x1,y1],[x2,y2],...],如果取消操作则返回undefined
     * @example
      * const line = await this.actionDrawLineString();
      * if (!line) return;
      * // 输出线的所有点坐标
      * for (let i = 0; i < line.length; i++) {
      * let x = line[i][0];
      * let y = line[i][1];
      * console.log(x, y);
      * }
     */
    async actionDrawLineString(isSnap)  {
            this.context.tools.logInfo("请在地图上绘制一条线")
            let snapObj = {};
            if (isSnap) {
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawLine = await vjmap.Draw.actionDrawLineSting(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawLine.cancel) {
                return;
            }
            let coords = drawLine.features[0].geometry.coordinates;
            return coords.map(c => {
                let p = this.map.fromLngLat(c);
                return [p.x, p.y];
            });
        }
    

    /**
     * 获取地图的缩略图
     * @param {object} options 参数 可选。
     * @param {string} [options.mapid] 地图ID. 可选,为空时则获取当前打开的地图
     * @param {string} [options.version] 版本号. 可选,为空时则获取当前打开的地图版本
     * @param {number} [options.width] 缩略图宽度. 可选
     * @param {number} [options.height] 缩略图高度. 可选
     * @param {boolean} [options.darkTheme] 是否是深色主题. 可选
     * @returns {string} 返回缩略图的URL地址
     * @example
      * // 示例一
      * // 获取地图sys_hello的缩略图
      * let url1 = this.thumbnailUrl({
      * mapid: "sys_hello"
      * });
      * console.log(url1);
      * // 示例二
      * // 获取地图sys_hello的缩略图,版本v1, 宽度200,高度200,深色主题
      * let url2 = this.thumbnailUrl({
      * mapid: "sys_hello",
      * version: "v1",
      * width: 200,
      * height: 200,
      * darkTheme: true
      * });
      * console.log(url2);
     */
    thumbnailUrl(options)  {
           let svc = this.map.getService();
           return svc.thumbnailUrl(options.mapid, options.version, options.width, options.height, options.darkTheme);
       }
    

    /**
     * 缩放至地图范围
     * @param {Object} [options] 缩放选项
     * @param {boolean} [options.linear] 如果true,则地图使用Map#easeTo进行转换。如果false,则地图使用Map#flyTo进行转换
     * @param {Function} [options.easing] 动画过渡的缓动函数
     * @param {Array<number>} [options.offset] 相对于地图中心的给定边界的中心,以像素为单位(默认[0,0])
     * @param {number} [options.maxZoom] 当地图视图转换到指定边界时允许的最大缩放级别
     * @param {boolean} [options.fitFillClip] 默认为窗口包含地图,如果要使地图占满窗口超出的部分裁剪,请设置为true
     * @param {Object} [eventData] 要添加到此方法触发的事件的事件对象的附加属性
     * @param {boolean} [options.isFlash] 是否使用闪烁动画,默认false
     * @example
      * // 示例一
      * // 缩放至地图范围[0,0,10,10],并添加10像素的填充
      * this.fitMapBounds([0,0,10,10], {padding: 10});
      * // 示例二
      * // 缩放至全图显示
      * this.fitMapBounds();
     */
    fitMapBounds(bounds, options, eventData)  {
            if (Array.isArray(bounds)) {
                bounds = vjmap.GeoBounds.fromArray(bounds);
            }
            let oldBounds = this.map.fromLngLat(this.map.getBounds()); // 获取当前地图范围
            this.map.fitMapBounds(bounds, options, eventData) // 缩放至地图范围
            if (options.isFlash === true) {
                __flashBounds(typeof bounds === 'number' ? this.map.getGeoBounds(bounds) : bounds);
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.fitMapBounds(oldBounds);
            });
         }
    

    /**
     * 切换至栅格瓦片样式
     * @example
      * // 切换至栅格瓦片样式
      * this.switchVectorToRasterStyle();
     */
    switchVectorToRasterStyle()  {
            // 如果当前地图已经使用栅格瓦片样式,则不进行切换
            if (!this.map.hasVectorLayer()) {
                return
            }
            this.map.switchVectorToRasterStyle(this.map.getService().rasterTileUrl());
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.switchRasterToVectorStyle(this.map.getService().vectorTileUrl());
            });
        }
    
    

    /**
     * 根据根据的坐标位直接绘制一个点符号
     * @param {[number, number]} point 点符号的坐标[x, y],参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.icon 符号图标名称,默认为_markerIcon_,参数可选
     * @param {number} options.iconSize 符号图标放大倍数,默认为1,参数可选
     * @param {number} options.iconRotate 符号图标旋转角度,默认为0,参数可选
     * @param {string} options.text 符号文本内容,默认为空,参数可选
     * @param {string} options.textColor 符号文本颜色,默认为空,参数可选
     * @param {number} options.textSize 符号文本大小,默认为22,参数可选
     * @param {number} options.textRotate 符号文本旋转角度,默认为0,参数可选
     * @param {number} options.textOpacity 符号文本透明度,默认为0,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 在位置[10, 20]处绘制一个点符号
      * const pt = this.createSymbol([10, 20]); // 启用捕捉功能采绘制一个点符号
      * if (!pt) return;
      * // 点的坐标
      * let point = pt.point;
      * const x = point[0];
      * const y = point[1];
      * console.log(x, y);
      * // 图元ID
      * let id = pt.id;
      * console.log(id);
      * // 示例二
      * // 在地图范围内随机生成1个点, 在这个点位置绘制一个点符号,符号图标名称为_pulsingDot_
      * let points = this.randomPointInMapBounds(1);
      * const pt2 = this.createSymbol(points[0], {
      * icon: "_pulsingDot_"
      * });
      * console.log(pt2);
      * // 示例三
      * // 在地图范围内随机生成10个点, 根据这些位置分别绘制点符号,符号图标名称为空,文本内容为当前坐标值, 颜色为红色
      * let points2 = this.randomPointInMapBounds(10);
      * for (let i = 0; i < points2.length; i++) {
      * let coord = points2[i];
      * this.createSymbol(coord, {
      * icon: "",
      * text: `[${coord[0].toFixed(2)}, ${coord[1].toFixed(2)}]`,
      * textColor: "#FF0000"
      * });
      * }
     */
    createSymbol(point, options)  {
            options = options || {};
            if (!point) return;
            let draw = this.map.getDrawLayer();
            let id = vjmap.RandomID(10)
            let icon = options.icon;
            if (icon === undefined) icon = "_markerIcon_";
            let onlyText = options.text && !icon;
            let symbolAttr = icon ? {
                "icon_image": icon, 
                "icon_size": options.iconSize || 1,
                "icon_rotate": options.iconRotate || 0,
            } : undefined;
    
            let textAttr = options.text ? {
                "text": options.text, 
                "text_size": options.textSize,
                "text_rotate": options.textRotate,
                "text_opacity": options.textOpacity,
                "color": options.textColor
            } : undefined
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: 'Point',
                    coordinates: this.map.toLngLat(point)
                },
                properties: {
                    "symbol": true,
                    "onlyText": onlyText,
                    "data": options.data,
                    ...symbolAttr, 
                    ...textAttr,
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                point
            };
        }
    

    /**
     * 删除地图
     * @param {object} options 参数
     * @param {string} options.mapid 地图ID
     * @param {string} options.version 版本号,如删除所有版本,输入"*"号
     * @param {number} [options.retainVersionMaxCount] 删除所有版本时,保留的最新的版本总数。可选
     * @returns {Promise<boolean>} 返回删除结果true表示成功,false表示失败
     * @example
      * // 示例一
      * // 删除地图hello的所有版本
      * let res1 = await this.deleteMap({
      * mapid: "hello",
      * version: "*"
      * });
      * console.log(res1);
      * // 示例二
      * // 删除地图hello的v1版本
      * let res2 = await this.deleteMap({
      * mapid: "hello",
      * version: "v1"
      * });
      * console.log(res2);
     */
    async deleteMap(options)  {
           let svc = this.map.getService();
           let res = await svc.cmdDeleteMap(options.mapid, options.version, options.retainVersionMaxCount);
           return res && res.status;
       }
    

    /**
     * 创建线数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.lineColor 线条颜色,参数可选,默认为'#ff0000'
     * @param {number} options.lineWidth 线宽,参数可选,默认为1
     * @param {number} options.lineOpacity 线透明度,参数可选,取值范围0-1
     * @param {number} options.lineGapWidth 线间隙宽度,参数可选,默认为1,单位像素
     * @param {number} options.lineOffset 线的偏移量,参数可选。正值向右/内偏移,负值向左/外偏移
     * @param {number} options.lineBlur 线模糊度,参数可选,需小于线宽度
     * @param {[number,number]} options.lineDasharray 虚线样式,参数可选,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,参数可选,格式如[x,y],负数表示左和上,单位像素
     * @param {string} options.lineCap 线帽形状,参数可选,可选值:'butt'(尖头)、'round'(圆头)、'square'(平头)
     * @param {string} options.lineJoin 拐角形状,参数可选,可选值:'bevel'(平拐)、'round'(圆拐)、'miter'(棱拐)
     * @param {string} options.linePattern 线图案,参数可选,需与预加载的图片名称对应,图像宽度必须是2的幂次
     * @param {string} options.lineGradient 线渐变,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer17的线数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createLineLayer(geojson, {
      * layerName: 'layer17'
      * });
      * console.log(layer);
     */
    async createLineLayer(data, options)  {
            options = options || {};
            let type = "line";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                lineColor: '#ff0000',
                lineWidth: 1,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createLineLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建矢量瓦片图层
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.tileMapId 瓦片的mapid,参数可选
     * @param {string} options.tileMapVersion 瓦片的版本,参数可选
     * @param {string} options.tileMapLayer 瓦片的样式图层名称,参数可选
     * @param {string|Array<string>} options.tiles 瓦片地址,支持变量 {x},{y},{z},{serviceUrl},{accessToken}
     * @param {number} options.tileSize 瓦片大小,参数可选,默认值为 512
     * @param {number[]} options.bounds 瓦片范围,参数可选,格式为[minx, miny, maxx, maxy],默认为全图范围
     * @param {string} options.scheme 瓦片y方向,参数可选,可选值为 xyz(Y从顶部开始)、tms(Y从底部开始),默认为 xyz
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 创建矢量瓦片图层, 瓦片的mapid为sys_hello
      * let layer = await this.createVectorLayer({
      * tileMapId: "sys_hello",
      * });
      * console.log(layer);
     */
    async createVectorLayer(options)  {
            options = options || {};
            let type = "vector";
    
            let randomId = vjmap.RandomID();
            let sourceId = `source_${type}_${randomId}`;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                sourceId,
                layerId,
                ...options,
                type: type
            }
    
            if (options.tileMapId && !options.tiles) {
                let layer = options.tileMapLayer;
                if (!layer) {
                    let style = await this.map.getService().createStyle({
                        backcolor: this.map.getService().currentMapParam().darkMode ? 0x000000 : 0xFFFFFF
                    }, options.tileMapId, options.tileMapVersion);
                    layer = style.stylename
                }
                let tileUrl = this.map.getService().vectorTileUrl({
                    mapid: options.tileMapId,
                    version: options.tileMapVersion,
                    layer: layer,
                })
                options.tiles = tileUrl;
            }
            if (options.bounds) {
                const p1 = this.map.toLngLat([options.bounds[0], options.bounds[1]]);
                const p2 = this.map.toLngLat([options.bounds[2], options.bounds[3]]);
                options.bounds = [p1[0], p1[1], p2[0], p2[1]];
            }
            let sourceData = {
                type: "vector",
                tiles: Array.isArray(options.tiles) ? options.tiles : [options.tiles],
                tileSize: options.tileSize || 512
            }
            if (options.bounds) {
                sourceData.bounds = options.bounds;
            }
            if (options.scheme) {
                sourceData.scheme = options.scheme;
            }
            this.map.addVectorSource(sourceId, sourceData);
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data: sourceData, options, layer, visible: true, create: this.createVectorLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 切换图纸工作区
     * @param {string} workspaceName 工作区名称, 可选,为空时则选择工作区
     * @example
      * // 切换图纸工作区
      * this.switchWorkspace();
     */
    async switchWorkspace(workspaceName)  {
            // 先获取默认的图层
            let svc = this.map.getService();
            let oldWorkspaceName = svc.getCurWorkspaceName();
            if (!workspaceName) {
                let workspaces = await svc.getWorkspaces() || [];
                let workspaceNames = workspaces.map(wp => wp.name + (wp.alias ? "[" + wp.alias + "]" : ""));
                let oldWorkspace = workspaces.find(wp => wp.name === oldWorkspaceName);
                if (oldWorkspace) {
                    oldWorkspaceName = oldWorkspace.name + (oldWorkspace.alias ? "[" + oldWorkspace.alias + "]" : "");
                }
                workspaceNames.unshift("[默认工作区]");
                workspaceName = await this.selectOptionsValue(workspaceNames, {
                    isMultiSelect: false,
                    title: "选择工作区",
                    initValue: oldWorkspaceName || "[默认工作区]"
                });
                if (!workspaceName) {
                    return;
                }
                if (workspaceName) {
                    // 取前面的名称
                    workspaceName = workspaceName.split("[")[0];
                }
            }
            
            svc.switchWorkspace(workspaceName);
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                svc.switchWorkspace(oldWorkspaceName);
            });
        }
    

    /**
     * 从服务端删除用户自定义数据
     * @param {string | string[]} key 键名,如果是数组的话,可以查询
     * @param {boolean} isPrefix 是否删除所有前缀为key的所有键值,默认false
     * @returns {Promise<boolean>} 返回删除是否成功, true表示成功,false表示失败
     * @example
      * // 从服务端删除键名为drawData的用户自定义数据
      * await this.deleteCustomDataServer("drawData");
     */
    async deleteCustomDataServer(key, isPrefix = false)  {
            let svc = this.map.getService();
            let res = await svc.deleteCustomData(key, isPrefix);
            return res?.status === "ok";
        }
    

    /**
     * 获取数据图层属性
     * @param {string} layerName 图层名称,参数必填
     * @returns {object | undefined} 返回图层属性对象, 如果没有找到图层,则返回undefined
     * @example
      * // 获取图层名称为layer1的数据图层属性
      * let layerName = 'layer1';
      * let property = this.getDataLayerProperty(layerName);
      * console.log("图层属性:", property);
     */
    getDataLayerProperty(layerName)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item) {
               return item.layer.mapLayer
            }
        }
    

    /**
     * 设置数据图层悬浮显示弹窗内容
     * @param {string} layerName 图层名称,参数必填
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {any} options.popupContent 弹窗内容,默认为当前数据的属性值
     * @param {boolean} options.popupShowInForm 弹窗内容是否以表单形式显示,参数可选,默认为false
     * @param {[number, number]} options.popupOffset 弹窗偏移量,参数可选,默认为[0, -40]
     * @param {number} options.popupWidth 弹窗宽度,参数可选
     * @param {number} options.popupHeight 弹窗高度,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选,默认为true
     * @param {boolean} options.noShowPopup 是否不显示弹窗,参数可选,默认为false
     * @param {Function} options.hoverCallback 悬浮回调函数,参数可选,默认为null,(回调函数第一个参数为弹窗内容)
     * @example
      * // 示例一
      * // 设置图层名称为layer1的数据图层悬浮显示弹窗
      * this.setDataLayerHoverPopupContent('layer1');
      * // 示例二
      * // 设置图层名称为layer1的数据图层悬浮显示弹窗, 弹窗内容为"ID:${props.index}"
      * this.setDataLayerHoverPopupContent('layer1', {
      * popupContent: "ID:${props.index}",
      * });
     */
    setDataLayerHoverPopupContent(layerName, options)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(!item) return;
            options = options || {};
            options.isHoverPointer = options.isHoverPointer === undefined ? true : options.isHoverPointer;
            let markers = item.layer.markers;
            if (Array.isArray(markers)) {
                // 如果是Marker相关的图层
                for(let m = 0; m < markers.length; m++) {
                    let marker = markers[m];
                    let oldCursor;
                    marker.on('mouseover', () => {
                        if (options.isHoverPointer) {
                            oldCursor = this.map.getCanvas().style.cursor;
                            this.map.getCanvas().style.cursor = "pointer";
                        }
                        let popup = this.context.global.popup;
                        if (!popup && options.noShowPopup !== true) {
                            popup = new vjmap.Popup({
                                offset: options.popupOffset || [0, -40],
                                closeOnClick: false, 
                                closeButton: true, 
                                anchor: "bottom" 
                            })
                            this.context.global.popup = popup;
                        }
                        if (options.noShowPopup !== true &&options.popupOffset) {
                            popup.setOffset(options.popupOffset);
                        }
                        let content = options.popupContent;
                        if (item.data && item.data.features && item.data.features[m] && item.data.features[m].properties && typeof content == "string" && !(content in item.data.features[m].properties)) {
                            content = item.layer.evalValue("return `" + content + "`", item.data.features[m].properties, this.map);
                            if (options.noShowPopup !== true) {
                                popup.setHTML(content);
                            }
                            if (options.hoverCallback) {
                                options.hoverCallback(content);
                            }
                        } else {
                            if (!content) {
                                content = item.data.features[m].properties;
                            } else {
                                // 如果content是对象的属性,则获取对象的属性值
                                if (item.data.features[m].properties && (content in item.data.features[m].properties)) {
                                    content = item.data.features[m].properties[content];
                                    try {
                                        // 如果content是json字符串,则尝试转换为对象
                                        content = JSON.parse(content);
                                    } catch (e) {}
                                }
                            }
                            if (options.noShowPopup !== true) {
                                const dom = this.context.ui.createElementByJsonData(content, options.popupShowInForm, {
                                    width: options.popupWidth,
                                    height: options.popupHeight
                                })
                                popup.setDOMContent(dom.element)
                            }
                            if (options.hoverCallback) {
                                options.hoverCallback(content);
                            }
                        }
                        if (options.noShowPopup !== true) {
                            popup.setLngLat(marker.getLngLat());
                            popup.addTo(this.map);
                        }
                    });
                    marker.on('mouseleave', () => {
                        if (options.isHoverPointer && oldCursor) {
                            this.map.getCanvas().style.cursor = oldCursor;
                            oldCursor = null;
                        }
                        if (options.noShowPopup !== true) {
                            let popup = this.context.global.popup;
                            if (popup) {
                                popup.remove();
                                this.context.global.popup = null;
                            }
                        }
                        if (options.hoverCallback) {
                            options.hoverCallback(null);
                        }
                    });
                }
            } else {
                // 如果是其他图层
                let oldCursor;
                let oldFeatureId;
                let layerId = item.layerId;
                let sourceId = item.sourceId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                    let style = this.map.getStyle();
                    let layer = style.layers.find(layer => layer.id == layerId);
                    if (layer && layer.source) {
                        sourceId = layer.source;
                    }
                }
                this.map.on("mouseover", layerId, (ev) => {
                    if (!ev || !ev.features || !ev.features[0]) return;
                    if (options.isHoverPointer) {
                        oldCursor = this.map.getCanvas().style.cursor;
                        this.map.getCanvas().style.cursor = "pointer";
                    }
                    let pt = ev.lngLat;
                    let popup = this.context.global.popup;
                    if (!popup && options.noShowPopup !== true) {
                        popup = new vjmap.Popup({
                            offset: options.popupOffset || [0, -40],
                            closeOnClick: false, 
                            closeButton: true, 
                            anchor: "bottom" 
                        })
                        this.context.global.popup = popup;
                    }
                    if (options.noShowPopup !== true && options.popupOffset) {
                        popup.setOffset(options.popupOffset);
                    }
                    let content = options.popupContent;
                    if (ev.features[0].properties && typeof content == "string" && !(content in ev.features[0].properties)) {
                        content = item.layer.evalValue("return `" + content + "`", ev.features[0].properties, this.map);
                        if (options.noShowPopup !== true) {
                            popup.setHTML(content);
                        }
                        if (options.hoverCallback) {
                            options.hoverCallback(content);
                        }
                    } else {
                        if (!content ) {
                            content = ev.features[0].properties;
                        } else {    
                            // 如果content是对象的属性,则获取对象的属性值
                            if (ev.features[0].properties && (content in ev.features[0].properties)) {
                                content = ev.features[0].properties[content];
                                try {
                                    // 如果content是json字符串,则尝试转换为对象
                                    content = JSON.parse(content);
                                } catch (e) {}
                            }
                        }
                        if (options.noShowPopup !== true) {
                            const dom = this.context.ui.createElementByJsonData(content, options.popupShowInForm, {
                                width: options.popupWidth,
                                height: options.popupHeight
                            })
                            popup.setDOMContent(dom.element)
                        }
                        if (options.hoverCallback) {
                            options.hoverCallback(content);
                        }
                    }
                    if (options.noShowPopup !== true) {
                        popup.setLngLat(pt);
                        popup.addTo(this.map);
                    }
                    oldFeatureId = ev.features[0].id;
                    this.map.setFeatureState({ source: sourceId, sourceLayer: layerId, id: ev.features[0].id }, { hover: true });
                });
                this.map.on("mouseleave", layerId, () => {
                    if (options.isHoverPointer && oldCursor) {
                        this.map.getCanvas().style.cursor = oldCursor;
                        oldCursor = null;
                    }   
                    if (options.noShowPopup !== true) {
                        let popup = this.context.global.popup;
                        if (popup) {
                            popup.remove();
                            this.context.global.popup = null;
                        }
                    }
                    if (options.hoverCallback) {
                        options.hoverCallback(null);
                    }
                    if (oldFeatureId) {
                        this.map.setFeatureState({ source: sourceId, sourceLayer: layerId, id: oldFeatureId }, { hover: false });
                        oldFeatureId = null;
                    }
                });
            }
        }
    

    /**
     * 采集一个斜矩形的坐标
     * @param {boolean} isSnap 是否启用捕捉功能, 默认false
     * @returns {Promise<number[][] | undefined>} 返回包含四个点坐标的数组[[x1,y1],[x2,y2],[x3,y3],[x4,y4]],如果取消操作则返回undefined
     * @example
      * const rect = await this.actionDrawSlantRectangle();
      * if (!rect) return;
      * console.log(rect); // 斜矩形的四个点坐标
     */
    async actionDrawSlantRectangle(isSnap)  {
            this.context.tools.logInfo("请在地图绘一个斜矩形")
            let snapObj = {};
            if (isSnap) {
                vjcommon.getMapSnapPoints(this.map, snapObj);
            }
            let drawRect = await vjmap.Draw.actionDrawSlantRectangle(this.map, isSnap ? {
                api: {
                    getSnapFeatures: snapObj
                }
            } : {});
            if (drawRect.cancel) {
                return;
            }
            let coords = drawRect.features[0].geometry.coordinates[0];
            return coords.map(c => {
                let p = this.map.fromLngLat(c);
                return [p.x, p.y];
            });
        }
    

    /**
     * 移除地图比例尺控件
     * @example
      * // 移除地图比例尺控件
      * this.removeMapScaleControl();
     */
    removeMapScaleControl()  {
            this.context.global.controls = this.context.global.controls || {};
            let options;
            if (this.context.global.controls.scaleControl) {
                options = {...this.context.global.controls.scaleControl.options}
                this.map.removeControl(this.context.global.controls.scaleControl.control);
                delete this.context.global.controls.scaleControl;
            }
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                if (options) {
                    this.addMapScaleControl(options);
                }
            });
        }
    
    

    /**
     * 拆分子图
     * @returns {Promise<string[]>} 返回拆分后的每个子图的fileid (数组次序与传入的子图范围数组clipBounds次序一致), 如果失败则返回undefined
     * @example
      * // 自动提取子图范围,获取返回的子图范围数组,拆分子图
      * let res = await this.findChildMapRects();
      * if (!res) return;
      * let fileids = await this.splitChildMaps({
      * clipBounds: res.childMapBounds
      * });
      * console.log(fileids);
     */
    async splitChildMaps(options)  {
           options = options || {};
           let svc = this.map.getService();
           if (!options.clipBounds || (options.clipBounds && options.clipBounds.length == 0)) {
                if (this.map.logInfo) this.map.logInfo('参数范围为空', "error", 10000);
                return;
           }
           for(let n = 0; n < options.clipBounds.length; n++) {
            if (Array.isArray(options.clipBounds[n]) && options.clipBounds[n].length == 4) {
                options.clipBounds[n] = options.clipBounds[n].join(',');
            }
           }
           let result = await svc.cmdSplitChildMaps({
            // 方法 cloneObjects 通过深度克隆实体,效率最快(默认),  cloneDb 通过克隆文档数据库,效率较快;cloneMap 通过克隆图,效率较慢,但最能保持原样
            method: "cloneObjects",
            // 是否启动新进程处理(不影响主进程,看初始速度慢些) 默认true
            startNewProcess: true,
            // 拆分后的图是否全图 默认false 
            isFullExtent: true,
            ...options
           });
           if (result && result.error) {
               if (this.map.logInfo) this.map.logInfo(result.error, "error", 10000);
               return;
           }
           let fileids = result.fileids;
           if (fileids && fileids.length > 0) {
            for(let n = 0; n < fileids.length; n++) {
                // 去掉文件后缀
                fileids[n] = fileids[n].split(".")[0];
            }
           }
           return fileids;
       }
    

    /**
     * 根据给定的圆心和半径直接绘制一个圆
     * @param {[number, number]} center 圆心坐标[x,y],参数必填
     * @param {number} radius 半径,参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Object} 返回绘制的图元对象,返回的对象包含以下属性:
     * @example
      * // 创建一个地图范围内随机位置的圆, 圆的半径为地图宽度的1/40, 颜色随机,填充,透明度0.5
      * let points = this.randomPointInMapBounds(1);
      * let rect = this.getMapGeoBounds(); // 获取地图范围
      * let width = (rect[2] - rect[0]) / 40; // 矩形宽度为地图宽度的1/00
      * const circle = this.createCircle(points[0], width, {
      * color: vjmap.randomColor(),
      * isFill: true,
      * opacity: 0.5
      * });
      * console.log(`圆 ID:`, circle.id);
      * console.log(`圆 圆心:`, circle.center);
      * console.log(`圆 半径:`, circle.radius);
     */
    createCircle(center, radius, options)  {
            let draw = this.map.getDrawLayer();
            let coords = vjmap.getCirclePolygonCoordinates(center, radius);
            coords = coords.map(c => this.map.toLngLat(c));
            let id = vjmap.RandomID(10);
            draw.add({
                id,
                type: 'Feature',
                geometry: {
                    type: options.isFill ? 'Polygon' : 'LineString',
                    coordinates: options.isFill ? [coords] : coords
                },
                properties: {
                    color: options.color,
                    opacity: options.opacity,
                    data: options.data
                }
            });
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.getDrawLayer().delete(id);
            });
            return {
                id,
                center,
                radius
            };
        }
    

    /**
     * 关闭数据显示面板
     * @example
      * // 关闭数据显示面板
      * this.closeDataPanel()
     */
    closeDataPanel()  {
            this.context.ui.setDataPanelContent();   
         }
    
    

    /**
     * 删除CAD图实体对象
     * @param {boolean} rectSelect 是否矩形选择, false表示点选,true表示矩形选择, 参数可选, 默认false
     * @example
      * // 示例一
      * // 点选删除CAD图实体对象
      * this.deleteCadEntity(false);
      * // 示例二
      * // 矩形选择删除CAD图实体对象
      * this.deleteCadEntity(true);
     */
    async deleteCadEntity(rectSelect)  {
            let draw = this.map.getDrawLayer();
            if (!this.context.global.updateMapStyleObj) {
                this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
            }
            const updateMapStyleObj = this.context.global.updateMapStyleObj;
            // 保存旧的数据,用于撤销记录
            let oldHideObjectIds = new Set(updateMapStyleObj.hideObjectIds);
            const deleteEntitys = vjcommon.getTrackFeatureProperty(draw, "deleteEntitys") || [];
            const hideEntityObjectIds =
              vjcommon.getTrackFeatureProperty(draw, "hideEntityObjectIds") || [];
            const hideEntityIds = vjcommon.getTrackFeatureProperty(draw, "hideEntityIds") || [];
    
            await vjcommon.deleteCadEntity(this.map, draw, updateMapStyleObj,  this.map.logInfo.bind(this.map), async (content) => {
                return await this.context.ui.confirm(content, "提示", "warning");
              }, rectSelect);
    
            let newHideObjectIds = new Set(updateMapStyleObj.hideObjectIds);
            let diffObjectIds = newHideObjectIds.difference(oldHideObjectIds);
            // 添加撤销记录
            this.context.ui.addUndoRecord(async () => {
                await updateMapStyleObj.removeHideObjectIds(diffObjectIds);
                vjcommon.setTrackFeatureProperty(draw, {
                  deleteEntitys: Array.from(new Set(deleteEntitys)),
                  hideEntityObjectIds: Array.from(new Set(hideEntityObjectIds)),
                  hideEntityIds: Array.from(new Set(hideEntityIds)),
                });
            });
        }
    

    /**
     * 获取当前显示地图预览的url地址
     * @returns {Promise<string>} 返回当前显示地图的url地址
     * @example
      * // 获取当前显示地图预览的url地址
      * let url = await this.curMapPreviewUrl();
      * console.log(url);
     */
    curMapPreviewUrl()  {
            let svc = this.map.getService();
            let mapParam = svc.currentMapParam();
            let url = svc.baseUrl() + "_mapviewer?";
            let param = {};
            param["render"] = 1; // 默认几何栅格
            if (mapParam?.mapopenway == vjmap.MapOpenWay.Memory) {
                param["render"] = 0; // 内存直接打开
            } else if (mapParam?.mapopenway == vjmap.MapOpenWay.GeomRender && window.location.href.indexOf("vector=true") > 0) {
                param["render"] = 2; // 默认几何矢量
            }
    
            param["mapid"] = mapParam?.mapid;
            param["version"] = mapParam?.version;
            param["layer"] = mapParam?.layer;
    
            param["centerX"] = this.map.getCenter().lng;
            param["centerY"] = this.map.getCenter().lat;
            param["zoom"] = this.map.getZoom();
            param["pitch"] = this.map.getPitch();
            param["bearing"] = this.map.getBearing();
            param["light"] = mapParam?.darkMode !== false;
    
            param["title"] = `唯杰地图vjmap-图名称:${mapParam?.mapid}-版本:${mapParam?.version}-样式:${mapParam?.layer}`;
    
            param["mobile"] = true;
            param['token'] = svc.accessToken;
            if (svc.getCurWorkspaceName()) {
                param['workspace'] = svc.getCurWorkspaceName();
            }
            url = url + Object.keys(param).map(item => item + "=" + param[item]).join("&");
            return url;
        }
    

    /**
     * 输出内容到会话窗口
     * @param {string} content 输出内容, 支持markdown格式
     * @example
      * // 将"123"输出至会话窗口
      * this.chatLog("123");
     */
    chatLog(content)  {
            return this.context.ui.chatLog(content) 
        }
    

    /**
     * 导出图纸布局空间
     * @param {object} options 参数
     * @param {string} options.mapid 地图ID. 可选,为空时则使用当前打开的地图
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {string} [options.layoutIndex] 布局索引,layoutIndex和layoutName只要输入一个就行,layoutIndex优先。如果都为空,则使用dwg当前的布局空间
     * @param {string} [options.layoutName] 布局名称,layoutIndex和layoutName只要输入一个就行,layoutIndex优先。如果都为空,则使用dwg当前的布局空间
     * @returns {Promise<string>} 返回导出的fileid, 如果失败则返回空字符串
     * @example
      * // 导出当前图纸布局空间,布局索引为0
      * let fileid = await this.exportLayout({
      * layoutIndex: "0"
      * });
      * console.log(fileid);
     */
    async exportLayout(options)  {
           let svc = this.map.getService();
           options = options || {};
           options.mapid = options.mapid || svc.currentMapParam().mapid;
           let res = await svc.cmdExportLayout(options);
           if (res && res.fileid) {
               return res.fileid;
           }
           return "";
       }
    

    /**
     * 允许或禁止地图旋转、倾斜、滚轮缩放、平移、双击缩放
     * @param {boolean} options.rotation 是否允许旋转(参数可选)
     * @param {boolean} options.pitch 是否允许倾斜(参数可选)
     * @param {boolean} options.zoom 是否允许滚轮缩放(参数可选)
     * @param {boolean} options.pan 是否允许平移(参数可选)
     * @param {boolean} options.dblclickZoom 是否允许双击缩放(参数可选)
     * @example
      * // 禁止地图旋转、倾斜、双击缩放, 允许滚轮缩放
      * this.setMapInteraction({rotation: false, pitch: false, zoom: true, dblclickZoom: false});
     */
    setMapInteraction(options)  {
            options = options || {};
            if (options.rotation === true) {
                this.map.dragRotate.enable();
                this.map.touchZoomRotate.enable(); 
                this.map.keyboard.enableRotation();
            } else if (options.rotation === false) {
                this.map.dragRotate.disable();
                this.map.touchZoomRotate.disable();
                this.map.keyboard.disable();
            }
    
            if (options.pitch === true) {
                this.map.setMinPitch(this.map.getPitch());
                this.map.setMaxPitch(this.map.getPitch());
            } else if (options.pitch === false) {
                this.map.setMinPitch(0);
                this.map.setMaxPitch(90);
            }
    
            if (options.zoom === true) {
                this.map.scrollZoom.enable();
                this.map.touchZoomRotate.enable();
            } else if (options.rotation === false) {
                this.map.scrollZoom.disable();
                this.map.touchZoomRotate.disable();
            }
    
            if (options.dblclickZoom === true) {
                this.map.doubleClickZoom.enable();
            } else if (options.dblclickZoom === false) {
                this.map.doubleClickZoom.disable();
            }
    
            if (options.pan === true) {
                this.map.dragPan.enable();
                this.map.touchZoomRotate.enable();
            } else if (options.pan === false) {
                this.map.dragPan.disable();
                this.map.touchZoomRotate.disable();
            }
        }
    

    /**
     * 通过数据获取数据范围大小
     * @param {Object} geojson 要获取范围的geojson数据,参数必填
     * @returns {[number, number, number, number]} 返回包含四个数字的数组[x1,y1,x2,y2],表示geojson数据范围的左下角和右上角坐标
     * @example
      * // 获取geojson数据范围大小
      * let geojson = {type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Point", coordinates: [10, 20]}}]};
      * let bounds = this.getDataGeoBounds(geojson);
      * console.log(bounds);
     */
    getDataGeoBounds(geojson)  {
            let dataExtent = vjmap.GeoBounds.fromDataExtent(geojson);
            return dataExtent.toArray();
        }
    

    /**
     * 自动提取图中的表格
     * @returns {Promise<GeoJSON>} 返回提取出的表格的GeoJSON数据, 如果失败则返回undefined
     * @example
      * //示例一
      * // 自动提取图中的表格
      * let geojson = await this.extractTale();
      * if (!geojson) {
      * console.log("提取表格失败");
      * } else {
      * console.log("提取表格成功, geojson数据为:", geojson);
      * }
      * //示例二
      * // 手动选择范围自动提取图中的表格
      * let res2 = await this.extractTale({
      * isSelectBounds: true
      * });
      * console.log(res2);
     */
    async extractTale(options)  {
           options = options || {};
           let svc = this.map.getService();
           options = {
            mapid: options.mapid || svc.currentMapParam().mapid,
            bounds: "",
            condition: "",
            debugInfo: [],
            digit: 4,
            tol: 0,
            tableEdgeMinPoint: 12,
            tableTextMinCount: 4,
            cellMaxArea: 90,
            cellEmptyRatio: 90,
            unLinkLineRatio: 20,
            tableMaxCellCount: 100000,
            noHvLineSegCount: 0,
            seachTableMost: false,
            version:  svc.currentMapParam()?.version,
            layer: svc.currentMapParam()?.layer,
            // 如果直接内存打开的话,用表达式查询,如果几何渲染打开,用空间查询
            geom: svc.currentMapParam()?.mapopenway != vjmap.MapOpenWay.Memory,
            ...options,
           };
           if (options.isSelectBounds) {
                // 如果是手动,先在图中选择一个区域
                if (this.map.logInfo) this.map.logInfo("请先选择表格所在的矩形区域,选择区域的范围需要覆盖表格内容", "success", 10000);
                 // 先在地图上绘制一个矩形,做为裁剪区域
                let snapObj = {}; // 设置的捕捉的实体
                vjcommon.getMapSnapPoints(this.map, snapObj);
                let res = await vjmap.Draw.actionDrawRectangle(this.map, {
                    api: {
                        getSnapFeatures: snapObj //要捕捉的数据项在后面,通过属性features赋值
                    },
                    contextMenu: (e) => {
                        // 给地图发送Enter键消息即可取消,模拟按Enter键
                        this.map.fire("keyup", {keyCode:13})
                    }
                });
                if (res.cancel) {
                    return // 取消操作
                }
                // 获取所绘制的坐标
                let rectCoord = this.map.fromLngLat(res.features[0].geometry.coordinates[0]);
                // 取左下角和右下角两个点
                let  bounds = [rectCoord[0].x, rectCoord[0].y, rectCoord[2].x, rectCoord[2].y];
                options.bounds = bounds.join(',');
           }
           if (Array.isArray(options.bounds)) {
            options.bounds = JSON.stringify(options.bounds);
           }
           if (options.showSettingForm !== false) {
            options = await this.showDataModifyDlg({
                data: options,
                title: "自动提取表格设置",
                showForm: true
            })
            if (!options) return;
           }
           let result = await svc.cmdExtractTale(options);
           if (result && result.error) {
                if (this.map.logInfo) this.map.logInfo(result.error, "error", 10000);
                return;
           }
           let tables = result.tables || [];
           let geoDatas = {
                "type": "FeatureCollection",
                "features": []
            }
            for(let t = 0; t < tables.length; t++) {
                let rect = vjmap.GeoBounds.fromString(tables[t].rect);
                let pts = rect.toPointArray();
                pts.push(pts[0]); // 闭合
                geoDatas.features.push(
                    {
                        "id": t,
                        "type": "Feature",
                        "properties": {
                            color: vjmap.randomColor(),
                            index: t,
                            data: tables[t],
                            tableDatas: tables[t].datas
                        },
                        "geometry": {
                            "coordinates": [pts],
                            "type": "Polygon"
                        }
                    })
            }
           return geoDatas;
       }
    

    /**
     * 创建荧光点数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer14的荧光点数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createFluorescenceMarkerLayer(geojson, {
      * layerName: 'layer14'
      * });
      * console.log(layer);
     */
    async createFluorescenceMarkerLayer(data, options)  {
            options = options || {};
            let type = "fluorescenceMarker";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                width: 20,
                markerHeight: 20,
                color1: "#ff0000",
                color2: "#ffff00",
                textFontSize: 15,
                textColor: "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createFluorescenceMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 删除所有功能按钮
     * @example
      * // 删除所有功能按钮
      * this.deleteButtonItems()
     */
    deleteButtonItems()  {
             this.context.ui.deleteButtonItems();   
          }
    
    

    /**
     * 创建旋转的文本框数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer28的旋转的文本框数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createTextBorderMarkerLayer(geojson, {
      * layerName: 'layer28'
      * });
      * console.log(layer);
     */
    async createTextBorderMarkerLayer(data, options)  {
            options = options || {};
            let type = "textBorderMarker";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                width: 40,
                markerHeight: 20,
                color1: "#ff0000",
                color2: "#ffff00",
                textFontSize: 15,
                textColor: "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createTextBorderMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 投影prj文件WKT字符转proj4字符串
     * @param {string} wkt 投影prj文件WKT字符
     * @param {string} [from] 字符串来源,为空为话为WKT
     * @returns {Promise<string>} 返回proj4字符串
     * @example
      * // 将WKT字符串`PROJCS["CGCS2000 / 3-degree Gauss-Kruger CM 111E",GEOGCS["China Geodetic Coordinate System 2000",DATUM["China_2000",SPHEROID["CGCS2000",6378300,300,AUTHORITY["EPSG","1024"]],AUTHORITY["EPSG","1043"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.018,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4490"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",112.1],PARAMETER["scale_factor",1],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","4546"]]`转换为proj4字符串
      * let proj4String = await this.prjWktToPrj4(`PROJCS["CGCS2000 / 3-degree Gauss-Kruger CM 111E",GEOGCS["China Geodetic Coordinate System 2000",DATUM["China_2000",SPHEROID["CGCS2000",6378300,300,AUTHORITY["EPSG","1024"]],AUTHORITY["EPSG","1043"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.018,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4490"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",112.1],PARAMETER["scale_factor",1],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","4546"]]`);
      * console.log(proj4String);
     */
    async prjWktToPrj4(wkt, from)  {
           let svc = this.map.getService();
           let res = await svc.cmdPrjWktToPrj4(wkt, from);
           return res?.proj4;
       }
    

    /**
     * 通过数据内容显示数据面板
     * @param {any} data 数据内容,必填
     * @param {object} options 数据面板配置,可选
     * @param {string} options.title 数据面板标题,可选
     * @param {number} options.width 数据面板宽度,可选
     * @param {number} options.height 数据面板高度,可选
     * @param {number} options.left 数据面板左边距离,可选
     * @param {number} options.top 数据面板上边距离,可选
     * @param {string} options.position 数据面板位置, 值有'top-right'、'top-left'、'bottom-right'、'bottom-left',可选,默认"top-left"
     * @param {boolean} options.showForm 是否以表单形式显示,可选,默认false
     * @example
      * // 通过数据内容显示数据面板,数据为{"a":1,"b":2},数据面板标题为"数据查看",数据面板宽度为300,数据面板高度为200,数据面板左边距离为50,数据面板上边距离为100,数据面板位置为左上角,数据面板以表单形式显示
      * this.showDataPanel({a:1,b:2}, {title: "数据查看", width: 300, height: 200, left: 50, top: 100, position: "top-left", showForm: true})
     */
    showDataPanel(data, options)  {
            options = options || {};
            options.title = options.title || "数据查看";
            this.context.ui.setDataPanelContent(data, options);   
         }
    

    /**
     * 删除所有功能菜单
     * @example
      * // 删除所有功能菜单
      * this.deleteMenuItems()
     */
    deleteMenuItems()  {
            this.context.ui.deleteMenuItems();   
         }
    
    

    /**
     * 对坐标数据进行坐标转换
     * @param {string} srs 源坐标系名称,如 EPSG:4326
     * @param {string} crs 目标坐标系名称,如 EPSG:3857
     * @param {[number, number] | [number, number][]} points 要转换的坐标
     * @param {string | string[]} [fourParameter] 四参数(x偏移,y偏移,缩放,旋转弧度),可选,对坐标最后进行修正
     * @param {boolean} [isInverseFourParamter] 是否是上面四参数坐标的反算
     * @returns {Promise<[number, number] | [number, number][]>} 返回转换后的坐标
     * @example
      * // 对坐标数据进行坐标转换,将坐标[120.0, 30.0]从EPSG:4326转换到EPSG:3857
      * let transformedPoints = await this.coordTransform("EPSG:4326", "EPSG:3857", [120.0, 30.0]);
      * console.log(transformedPoints);
     */
    async coordTransform(srs, crs, points, fourParameter, isInverseFourParamter)  {
           let svc = this.map.getService();
           let isOnePoint = false;
           if (Array.isArray(points)) {
            if (points.length > 0 && !Array.isArray(points[0])) {
                isOnePoint = true;
                points = vjmap.geoPoint(points);
            } else {
                points = points.map((point) => vjmap.geoPoint(point));
            }
           }
           let result = await svc.cmdTransform(srs, crs, points, fourParameter, isInverseFourParamter);
           if (result && result.error) {
               if (this.map.logInfo) this.map.logInfo(result.error, "error", 10000);
               return;
           }
           if (isOnePoint) {
            return result[0];
           }
           return result;
       }
    

    /**
     * 弹出表单输入对话框
     * @param {object} formJsonSchema 表单的 JSON Schema 格式配置,包含表单字段、类型、校验规则和属性的定义。结构示例:
     * @returns {object} 返回用户输入的数据,格式为一个对象,其中每个字段的键为 `properties` 中的字段名,值为用户输入的值。例如:
     * @example
      * // 弹出学生表单输入对话框,包括姓名、年龄(默认18)、性别
      * let formJsonSchema = {
      * type: "object",
      * title: "学生信息表单",
      * properties: {
      * name: { type: "string", title: "姓名"},
      * age: { type: "number", title: "年龄", default: 18},
      * gender: { type: "string", title: "性别", enum: ["男", "女"]}
      * },
      * required: ["name", "age", "gender"]
      * }
      * let res = await this.showFormInputDialog(formJsonSchema);
      * let name = res.name;
      * let age = res.age;
      * let gender = res.gender;
      * console.log(name, age, gender)
     */
    async showFormInputDialog(formJsonSchema)  {
            return await this.context.ui.showFormInputDlg(formJsonSchema)
        }
    

    /**
     * 创建多边形数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.fillColor 填充颜色
     * @param {string} options.fillOutlineColor 边框颜色
     * @param {number} options.fillOpacity 填充透明度,取值范围0-1
     * @param {string} options.fillPattern 填充图案,必须与地图已加载的图片名称对应,图像宽度必须是2的系数(2、4、8、...、512)
     * @param {[number,number]} options.fillTranslate 几何体的平移量[x,y],负数分别表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillTranslateAnchor 平移参考系,"map"表示相对于地图平移,"viewport"表示相对于视窗平移
     * @param {boolean} options.fillAntialias 是否启用填充反锯齿
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer11的多边形数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createFillLayer(geojson, {
      * layerName: 'layer11'
      * });
      * console.log(layer);
     */
    async createFillLayer(data, options)  {
            options = options || {};
            let type = "fill";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillColor: "#00ffff",
                fillOutlineColor: "#00ff00",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createFillLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 根据内容生成二维码图片
     * @param {string} content 二维码内容
     * @param {object} options 选项
     * @param {number} options.size 二维码大小,默认256
     * @param {boolean} options.disableOpen 只返回地址,不打开图片,默认false
     * @returns {Promise<string>} 返回二维码图片的url
     * @example
      * // 根据"https://www.vjmap.com"生成二维码图片
      * let url = await this.qrcodeUrl("https://www.vjmap.com");
      * console.log(url);
     */
    async qrcodeUrl(content, options)  {
            options = options || {};
            let svc = this.map.getService();
            let res = await svc.qrcodeUrl(content, options.size);
            if (options.disableOpen) return res;
            window.open(res);
            return res;
        }
    

    /**
     * 手动交互式绘制一个点符号
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.icon 符号图标名称,默认为_markerIcon_,参数可选
     * @param {number} options.iconSize 符号图标放大倍数,默认为1,参数可选
     * @param {number} options.iconRotate 符号图标旋转角度,默认为0,参数可选
     * @param {string} options.text 符号文本内容,默认为空,参数可选
     * @param {string} options.textColor 符号文本颜色,默认为空,参数可选
     * @param {number} options.textSize 符号文本大小,默认为22,参数可选
     * @param {number} options.textRotate 符号文本旋转角度,默认为0,参数可选
     * @param {number} options.textOpacity 符号文本透明度,默认为0,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 手动绘制一个点符号
      * const pt = await this.drawSymbol(); // 启用捕捉功能采绘制一个点符号
      * if (!pt) return;
      * // 点的坐标
      * let point = pt.point;
      * const x = point[0];
      * const y = point[1];
      * console.log(x, y);
      * // 图元ID
      * let id = pt.id;
      * console.log(id);
      * // 示例二
      * // 手动绘制一个点符号,符号图标名称为_pulsingDot_
      * const pt2 = await this.drawSymbol({
      * icon: "_pulsingDot_"
      * });
      * console.log(pt2);
      * // 示例三
      * // 手动绘制一个点符号,符号图标名称为空,文本内容为"Hello",文本旋转角度为45
      * const pt3 = await this.drawSymbol({
      * text: "Hello",
      * textRotate: 45
      * });
      * console.log(pt3);
     */
    async drawSymbol(options)  {
            options = options || {};
            let point = await this.actionDrawPoint(options.isSnap);
            if (!point) return;
            return this.createSymbol(point, options)
        }
    

    /**
     * 通过范围创建空白地图
     * @param {number| [number,number,number,number] | GeoJSON} boundData 范围数据,可以是一个数值,表示地图宽高, 或一个数组表示地图范围, 或一个GeoJSON对象(会自动计算范围), 要为空时,则创建一个10000*10000的正方形地图
     * @example
      * // 示例一
      * // 创建一个空白地图
      * this.createBlankMap();
      * // 示例二
      * // 通过范围[100,100,200,200]创建空白地图
      * this.createBlankMap([100,100,200,200]);
     */
    createBlankMap(boundData)  {
            let dataExtent;
            boundData = boundData || 10000;
            if (typeof boundData === "number") {
                dataExtent = [-boundData/2, -boundData/2, boundData/2, boundData/2 ];
            } else if (Array.isArray(boundData) && boundData.length === 4 && typeof boundData[0] === "number") {
                dataExtent = vjmap.GeoBounds.fromArray(boundData);
            } else {
                dataExtent = vjmap.GeoBounds.fromDataExtent(boundData);
            }
            dataExtent = dataExtent.square(); // 地图的范围需要正方形,地图范围需要正方形才可以
            let mapBounds = dataExtent.scale(4); // 把范围调点大,这个值可以根据情况自己定,以后加的点不要超过此范围即可
    
            // 清空地图
            this.clearMapData({
                clearAllData: true
            });
            // 根据地图范围建立几何投影坐标系
            let prj = new vjmap.GeoProjection(mapBounds);
    
            let blankStyle = this.map.getService().rasterBlankStyle(0, 24)
            let sourceId = Object.keys(blankStyle.sources)[0];
            this.map.addRasterSource(sourceId, blankStyle[sourceId]);
            this.map.addLayer(blankStyle.layers[0]);
            this.map.setMapProjection(prj);
            // 打开新的地图了,需要清空历史记录
            this.context.ui.clearUndoRecord();
        }
    

    /**
     * 手动交互式绘制一个矩形
     * @param {object} options 配置参数, 参数可选
     * @param {boolean} options.isSnap 是否启用捕捉功能, 参数可选,默认false
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {boolean} options.isFill 是否填充,默认false,参数可选
     * @param {number} options.opacity 透明度,默认1,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 手动绘制一个矩形
      * const rect = await this.drawRectangle({
      * isSnap: true,
      * color: "#FF0000",
      * isFill: true,
      * opacity: 0.8
      * });
      * if (!rect) return;
      * console.log("矩形ID:", rect.id);
      * console.log("矩形坐标:", rect.points);
     */
    async drawRectangle(options)  {
            let points = await this.actionDrawRectangle(options.isSnap);
            if (!points) return;
            return this.createRectangle(points, options);
        }
    

    /**
     * 打开图, 通过指定地图id或手动选择打开图
     * @param {object} options 参数 可选
     * @param {string} options.mapid 地图id 可选,为空时则手动选择地图
     * @param {string} options.version 版本 可选,为空时则选择最新版本
     * @param {"Memory" | "GeomRaster" | "GeomVector"} options.openway 打开方式 可选,Memory: 内存, GeomRaster: 栅格, GeomVector: 矢量, 默认栅格
     * @param {boolean} options.lightTheme 是否使用浅色主题 可选,为空时则使用深色主题
     * @param {boolean} options.isFullExtent 是否全图范围显示 可选,默认false
     * @returns {Object | undefined} 返回对象,包含地图id和版本 {mapid: string, version: string}, 如果取消则返回undefined
     * @example
      * // 示例一
      * // 打开地图
      * this.openCadMap();
      * // 示例二
      * // 打开地图sys_world
      * this.openCadMap({
      * mapid: "sys_world"
      * });
      * // 示例三
      * // 打开地图sys_hello, 版本v1, 以矢量方式打开, 使用浅色主题
      * this.openCadMap({
      * mapid: "sys_hello",
      * version: "v1",
      * openway: "GeomVector",
      * lightTheme: true
      * });
     */
    async openCadMap(options)  {
            options = options || {};
            let mapid = options.mapid || "";
            let version = options.version || "";
            let mapopenway = vjmap.MapOpenWay.GeomRender;
            let isVectorStyle = false;
            let lightTheme = options.lightTheme ?? (this.map.getService().currentMapParam()?.darkMode === true ? false : true)
            if (!mapid) {
                let res = await this.context.ui.selectCadMap()
                if (!res) return;
                mapid = res.mapid;
                version = res.version;
                mapopenway = res.openway;
                isVectorStyle = res.isVectorStyle;
            } else {
                mapopenway = options.openway === "Memory" ? vjmap.MapOpenWay.Memory : vjmap.MapOpenWay.GeomRender;
                isVectorStyle = options.openway === "GeomVector" ? true : false;
            }
            // 打开地图
            let res = await this.map.switchMap({
                mapid: mapid,
                version: version,
                mapopenway: mapopenway,
                style: lightTheme ? vjmap.openMapLightStyle() : vjmap.openMapDarkStyle(),
                // 如果有密码保护的图,要求输入密码回调,如果不传回调函数的话,将用系统的prompt提示输入
                cbInputPassword: (param) => {
                    return new Promise((resolve) => {
                        if (param.tryPasswordCount > 3) {
                            resolve('');// 如果密码重试次数超过三次
                        } else {
                            this.messageBoxPrompt("请输入密码或AccessKey", `打开图 ${param.mapid} 需要密码`, "", true)
                            .then((value) => {
                                resolve(value) ;
                            })
                            .catch(() => {
                                resolve('') ;
                            })
                        }
                    })
                }
            }, false, isVectorStyle, true, true);
            if (options.isFullExtent !== true) {
                // 用默认的中心点和缩放级别参数
                let svc = this.map.getService();
                let param = svc.currentMapParam();
                if (param && param.view) {
                    if (param.view.center) {
                        this.map.setCenter(param.view.center);
                    }
                    if (param.view.zoom) {
                        this.map.setZoom(param.view.zoom);
                    }
                    if (param.view.bearing) {
                        this.map.setBearing(param.view.bearing);
                    }
                }
            }
            if (res && res.error) {
                this.showMessage(res.error)
                return;
            }
            // 打开新的地图了,需要清空历史记录
            this.context.ui.clearUndoRecord();
            return {
                mapid: mapid,
                version: version
            };
    
        }
    

    /**
     * 设置绘制图层的图元数据
     * @param {<GeoJSON | undefined>} data 图元数据
     */
    setDrawLayerData(data)  {
            let draw = this.map.getDrawLayer();
            draw.set(this.map.toLngLat(data));
        }
    

    /**
     * 叠加互联网地图
     * @param {object} options 叠加配置选项
     * @param {string} [options.epsg] cad图epsg代号
     * @param {"beijing54"|"xian80"|"cgs2000"|""} [options.crs] cad图的坐标系,beijing54(北京54坐标)、xian80(西安80坐标、cgs2000(CGCS2000坐标) 或 空
     * @param {number} [options.webmaptype] 叠加的互联网地图类型,1:高德地图,2:高德影像,3:天地图,4:天地图影像
     * @returns {Promise<string>} 返回叠加的图层名称
     * @example
      * // 示例一
      * // 叠加互联网地图,cad图的坐标系为2000坐标
      * let layerName = await this.overlayWebMap({
      * crs: "cgs2000"
      * });
      * console.log("layerName", layerName);
      * // 示例二
      * // 叠加天地图影像地图,cad图的坐标系为西安80坐标
      * let layerName2 = await this.overlayWebMap({
      * crs: "xian80",
      * webmaptype: 4
      * });
      * console.log("layerName", layerName2);
      * // 示例三
      * // 叠加互联网地图
      * let layerName3 = await this.overlayWebMap();
      * console.log("layerName", layerName3);
     */
    async overlayWebMap(options)  {
            options = {...options}
            // 判断底图是否为互联网地图
            let isWebMap = this.map.getMapProjection() instanceof vjmap.LnglatProjection;
            if (isWebMap) {
                this.showMessage("当前地图已经是互联网地图,无法叠加");
                return;
            }
            let epsg = options.epsg;
            if (!epsg) {
                epsg = await this.getCadEpsgCode(options);
            }
            let webmaptype = options.webmaptype ?? 1;
            let fp;
            if (!epsg) {
               // 用四参数叠加, 左边是默认地图,右边是互联网地图
               fp = await this.context.ui.getFourParamter({}, {webmaptype: webmaptype});
               if (!fp) return;
                if (fp.webmaptype == 1 || fp.webmaptype == 2) {
                    // 高德地图
                    options.overMapType = "GCJ02";
                    if (fp.webmaptype == 2) {
                        // 影像
                        options.overMapImage = true;
                    }
                } else if (fp.webmaptype == 3 || fp.webmaptype == 4) {
                    // 天地图
                    options.overMapType = "WGS84";
                    if (fp.webmaptype == 4) {
                        // 影像
                        options.overMapImage = true;
                    }
                }
                options.isSetRotateZero = !fp.allowsRotation;
                options.coordinates = [];
                for(let n = 0; n < fp.leftMarkers.length; n++) {
                    let leftMarker = fp.leftMarkers[n];
                    let rightMarker = fp.rightMarkers[n];
                    options.coordinates.push({
                        x1: rightMarker.x,
                        y1: rightMarker.y,
                        x2: leftMarker.x,
                        y2: leftMarker.y
                    });
                }
                options.overlayType = "param";
            } else {
                options.overlayType = "auto";
                if (webmaptype == 1 || webmaptype == 2) {
                    // 高德地图
                    options.overMapType = "GCJ02";
                    if (webmaptype == 2) {
                        // 影像
                        options.overMapImage = true;
                    }
                } else if (webmaptype == 3 || webmaptype == 4) {
                    // 天地图
                    options.overMapType = "WGS84";
                    if (webmaptype == 4) {
                        // 影像
                        options.overMapImage = true;
                    }
                }
            }
            let wmsTileUrl;
            if (options.overlayType == "param") {
                // 四参数叠加
                let b = this.map.getMapExtent();
                if (options.overMapType == "WGS84") {
                    // 天地图
                    let webMapTiles = vjcommon.tiandituProviderTiles(options.overMapImage);   
                    const tiles = webMapTiles.map(t => vjcommon.getTileShards(t)) || [];
                    wmsTileUrl = this.map.getService().webMapUrl({
                        tileCrs: "wgs84",
                        tileUrl: tiles?.map(t => t.tileUrl) ?? '',
                        tileShards: (tiles.length >= 0) ? tiles[0].tileShards : '',
                        tileToken: "",
                        tileSize: 256,
                        tileRetina: 1,
                        tileMaxZoom: 18,
                        tileFlipY: false,
                        // @ts-ignore
                        mapbounds: JSON.stringify([b.min.x,b.min.y,b.max.x,b.max.y]),
                        srs:  "EPSG:3857",
                        fourParameterBefore: fp.fourParamter
                    })
                } else {
                    // 高德地图
                    let webMapTiles = vjcommon.gaodeProviderTiles(options.overMapImage);
                    const tiles = webMapTiles.map(t => vjcommon.getTileShards(t)) || [];
                    wmsTileUrl = this.map.getService().webMapUrl({
                        tileCrs: "gcj02",
                        tileUrl: tiles?.map(t => t.tileUrl) ?? '',
                        tileShards: (tiles.length >= 0) ? tiles[0].tileShards : '',
                        tileToken: "",
                        tileSize: 256,
                        tileRetina: 1,
                        // @ts-ignore
                        tileMaxZoom: 18,
                        tileFlipY: false,
                        mapbounds: JSON.stringify([b.min.x,b.min.y,b.max.x,b.max.y]),
                        srs:  "EPSG:3857",
                        fourParameterBefore: fp.fourParamter
                    })
                }
            } else {
                // 自动叠加
                wmsTileUrl = await this.getWmsTileUrl({
                    epsg: epsg,
                    overMapType: options.overMapType,
                    overMapImage: options.overMapImage,
                    isSetRotateZero: options.isSetRotateZero,
                    coordinates: options.coordinates,
                    overlayType: options.overlayType
                });
            }
            
            if (!wmsTileUrl) return;
            // 创建栅格瓦片图层
            let layer = await this.createRasterLayer({
                tiles: wmsTileUrl,
            });
            // 把图层移动到最下面
            this.moveLayer(layer.layerName, {
                bottomMost: true
            });
            return layer
         }
    

    /**
     * 修改CAD图实体对象
     * @param {boolean} rectSelect 是否矩形选择, false表示点选,true表示矩形选择, 参数可选, 默认false
     * @example
      * // 示例一
      * // 点选修改CAD图实体对象
      * this.modifyCadEntity(false);
      * // 示例二
      * // 矩形选择修改CAD图实体对象
      * this.modifyCadEntity(true);
     */
    async modifyCadEntity(rectSelect)  {
            let draw = this.map.getDrawLayer();
            if (!this.context.global.updateMapStyleObj) {
                this.context.global.updateMapStyleObj = vjcommon.createUpdateMapStyleObj(this.map);
            }
            const updateMapStyleObj = this.context.global.updateMapStyleObj;
            // 保存旧的数据,用于撤销记录
            let oldHideObjectIds = new Set(updateMapStyleObj.hideObjectIds);
            const deleteEntitys = vjcommon.getTrackFeatureProperty(draw, "deleteEntitys") || [];
            const hideEntityObjectIds =
              vjcommon.getTrackFeatureProperty(draw, "hideEntityObjectIds") || [];
            const hideEntityIds = vjcommon.getTrackFeatureProperty(draw, "hideEntityIds") || [];
            let features = draw.getAll().features;
            let oldFeatureLength = features ? features.length : 0;
    
            await vjcommon.modifyCadEntity(this.map, draw, updateMapStyleObj,  this.map.logInfo.bind(this.map), async (content) => {
                return await this.context.ui.confirm(content, "提示", "warning");
              }, rectSelect, (content) => {
                return this.context.ui.prompt("请输入内容", "提示", content);
              });
              
            let newHideObjectIds = new Set(updateMapStyleObj.hideObjectIds);
            let diffObjectIds = newHideObjectIds.difference(oldHideObjectIds);
            let addFeatureIds = [];
            let newFeatures = draw.getAll().features;
            let newFeatureLength = newFeatures ? newFeatures.length : 0;
            for (let i = oldFeatureLength; i < newFeatureLength; i++) {
                addFeatureIds.push(newFeatures[i].id);
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(async () => {
                await updateMapStyleObj.removeHideObjectIds(diffObjectIds);
                this.map.getDrawLayer().delete(addFeatureIds);
                vjcommon.setTrackFeatureProperty(draw, {
                  deleteEntitys: Array.from(new Set(deleteEntitys)),
                  hideEntityObjectIds: Array.from(new Set(hideEntityObjectIds)),
                  hideEntityIds: Array.from(new Set(hideEntityIds)),
                });
            });
        }
    

    /**
     * 创建信息窗口数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.html 信息窗口的HTML内容,支持props内置属性变量
     * @param {[number, number]} options.offset 以像素为单位的偏移量[x,y],对象相对于元素的中心。负数表示向左和向上,默认[0,0]
     * @param {string} options.anchor 信息窗口锚点位置,可选值:'center'、'top'、'bottom'、'left'、'right'、'top-left'、'top-right'、'bottom-left'、'bottom-right',默认'center'
     * @param {boolean} options.closeButton 是否显示关闭按钮,参数可选
     * @param {boolean} options.closeOnClick 是否在单击地图时关闭弹出窗口,参数可选
     * @param {boolean} options.closeOnMove 是否在地图移动后关闭信息窗口,参数可选
     * @param {boolean} options.focusAfterOpen 是否尝试聚焦弹出窗口内的第一个可聚焦元素,参数可选
     * @param {string} options.className 添加到弹出容器的以空格分隔的CSS类名,参数可选
     * @param {string} options.maxWidth 设置弹出窗口最大宽度的CSS属性字符串,如'300px'。设为'none'时自适应内容,默认'240px'
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer22的信息窗口数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createPopupDataLayer(geojson, {
      * layerName: 'layer22'
      * });
      * console.log(layer);
     */
    async createPopupDataLayer(data, options)  {
            options = options || {};
            let type = "popup";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                color: '#3FB1CE',
                html: "<span style='color:#0000ff'>index:${props.index}</span>",
                closeButton: true,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createPopupDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 增加鼠标位置控件
     * @param {number} options.digits 小数点位数,参数可选
     * @param {boolean} options.trackCenter 是否跟踪中心点位置,参数可选
     * @param {boolean} options.showLatLng 是否显示经纬度,参数可选
     * @param {boolean} options.showZoom 是否显示缩放级别,参数可选
     * @param {boolean} options.showBearing 是否显示方位角,参数可选
     * @param {boolean} options.showPitch 是否显示倾斜角,参数可选
     * @param {'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} options.position 控件位置,参数可选, 默认'top-right'
     * @example
      * // 增加鼠标位置控件,位置右下角
      * this.addMousePositionControl({ position: 'bottom-right' });
     */
    addMousePositionControl(options)  {
            this.context.global.controls = this.context.global.controls || {};
            if (this.context.global.controls.mousePositionControl) {
                this.map.removeControl(this.context.global.controls.mousePositionControl.control);
            }
            let mousePositionControl = new vjmap.MousePositionControl(options);
            this.map.addControl(mousePositionControl, options.position);
            this.context.global.controls.mousePositionControl = {
                control: mousePositionControl,
                position: options.position,
                options: options
            };
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.removeControl(mousePositionControl);
                delete this.context.global.controls.mousePositionControl;
            }); 
        }
    

    /**
     * 获取临时数据
     * @param {string} name 数据名
     * @returns {any} 数据内容
     * @example
      * // 获取临时数据test的值
      * this.getTempData("test");
     */
    getTempData(name)  {
            return this.context.resultData[name]    
        }
    

    /**
     * 显示消息内容
     * @param {string} message 消息内容,必填
     * @param {string} type 消息类型,可选值为警告("warning")、错误("error")、信息("info")、成功("success"),参数可选, 默认错误
     * @example
      * // 示例一
      * // 显示错误消息内容"出错了"
      * this.showMessage("出错了", "error");
      * // 示例二
      * // 显示成功消息内容"已完成"
      * this.showMessage("已完成", "success");
     */
    async showMessage(message, type)  {
            return await this.context.ui.showMessage(message, type || "error");
        }
    

    /**
     * 获取所有点标记Marker
     * @param {string} id 点标记Marker的id
     * @param {[number, number]} position 点标记Marker的坐标[x, y]
     * @param {string} data 点标记Marker的数据
     * @returns {Array<Object>} 返回所有点标记Marker, 每个Marker对象包含:
     * @example
      * // 获取所有点标记Marker
      * let markers = this.getAllMarkers();
      * for(let i = 0; i < markers.length; i++) {
      * let marker = markers[i];
      * let x = marker.position[0];
      * let y = marker.position[1];
      * console.log(marker.id, x, y, marker.data);
      * }
     */
    getAllMarkers()  {
            let markers = this.map.getMarkers();
            markers = markers.filter(m => m.id !== undefined);
            return markers.map(m => {
                let point = this.map.fromLngLat(m.getLngLat());
                return {
                    id: m.id,
                    position: [point.x, point.y],
                    data: m.data
                }
            });
         }
    

    /**
     * 获取绘制的全部图元
     * @returns {<GeoJSON | undefined>} 返回选中的GeoJSON对象
     * @example
      * // 获取绘制的全部图元的图元ID
      * const geojson = this.getDrawAll();
      * if (!geojson) return;
      * let ids = [];
      * for(let i = 0; i < geojson.features.length; i++) {
      * let feature = geojson.features[i];
      * ids.push(feature.id);
      * }
      * console.log(ids);
     */
    getDrawAll()  {
            let draw = this.map.getDrawLayer();
            return this.map.fromLngLat(draw.getAll());
        }
    
    

    /**
     * 获取地图的中心坐标
     * @returns {[number, number]} 当前地图中心的坐标,格式为[x,y]
     */
    getCenter()  {
            let center = this.map.fromLngLat(this.map.getCenter());
            return [center.x, center.y];
        }
    
    

    /**
     * 设置数据图层点击显示弹窗内容
     * @param {string} layerName 图层名称,参数必填
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {any} options.popupContent 弹窗内容,默认为当前数据的属性值
     * @param {boolean} options.popupShowInForm 弹窗内容是否以表单形式显示,参数可选,默认为false
     * @param {[number, number]} options.popupOffset 弹窗偏移量,参数可选,默认为[0, -40]
     * @param {number} options.popupWidth 弹窗宽度,参数可选
     * @param {number} options.popupHeight 弹窗高度,参数可选
     * @param {boolean} options.noShowPopup 是否不显示弹窗,参数可选,默认为false
     * @param {Function} options.clickCallback 点击回调函数,参数可选,默认为null(回调函数第一个参数为弹窗内容)
     * @example
      * // 示例一
      * // 设置图层名称为layer1的数据图层点击显示弹窗, 以表单形式展示
      * this.setDataLayerClickPopupContent('layer1', {
      * popupShowInForm: true
      * });
      * // 示例二
      * // 设置图层名称为layer2的数据图层点击显示弹窗, 弹窗内容为"ID:${props.index}"
      * this.setDataLayerClickPopupContent('layer2', {
      * popupContent: "ID:${props.index}",
      * });
     */
    setDataLayerClickPopupContent(layerName, options)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(!item) return;
            options = options || {};
            options.isHoverPointer = options.isHoverPointer === undefined ? true : options.isHoverPointer;
            let markers = item.layer.markers;
            if (Array.isArray(markers)) {
                // 如果是Marker相关的图层
                for(let m = 0; m < markers.length; m++) {
                    let marker = markers[m];
                
                    marker.on('click', () => {
                        let popup = this.context.global.popup;
                        if (!popup && options.noShowPopup !== true) {
                            popup = new vjmap.Popup({
                                offset: options.popupOffset || [0, -40],
                                closeOnClick: false, 
                                closeButton: true, 
                                anchor: "bottom" 
                            })
                            this.context.global.popup = popup;
                        }
                        if (options.noShowPopup !== true && options.popupOffset) {
                            popup.setOffset(options.popupOffset);
                        }
                        let content = options.popupContent;
                        if (item.data && item.data.features && item.data.features[m] && item.data.features[m].properties && typeof content == "string" && !(content in item.data.features[m].properties)) {
                            content = item.layer.evalValue("return `" + content + "`", item.data.features[m].properties, this.map);
                            if (options.noShowPopup !== true) {
                                popup.setHTML(content);
                            }
                            if (options.clickCallback) {
                                options.clickCallback(content);
                            }
                        } else {
                            if (!content) {
                                content = item.data.features[m].properties;
                            } else {
                                // 如果content是对象的属性,则获取对象的属性值
                                if (item.data.features[m].properties && (content in item.data.features[m].properties)) {
                                    content = item.data.features[m].properties[content];
                                    try {
                                        // 如果content是json字符串,则尝试转换为对象
                                        content = JSON.parse(content);
                                    } catch (e) {}
                                }
                            }
                            if (options.noShowPopup !== true) {
                                const dom = this.context.ui.createElementByJsonData(content, options.popupShowInForm, {
                                    width: options.popupWidth,
                                    height: options.popupHeight
                                })
                                popup.setDOMContent(dom.element)
                            }
                            if (options.clickCallback) {
                                options.clickCallback(content);
                            }
    
                        }
                        if (options.noShowPopup !== true) {
                            popup.setLngLat(marker.getLngLat());
                            popup.addTo(this.map);
                        }
                    });
                   
                }
            } else {
                // 如果是其他图层
                let layerId = item.layerId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                }
                this.map.on("click", layerId, (ev) => {
                    if (!ev || !ev.features || !ev.features[0]) return;
                   
                    let pt = ev.lngLat;
                    let popup = this.context.global.popup;
                    if (!popup && options.noShowPopup !== true) {
                        popup = new vjmap.Popup({
                            offset: options.popupOffset || [0, -40]
                        })
                        this.context.global.popup = popup;
                    }
                    if (options.noShowPopup !== true && options.popupOffset) {
                        popup.setOffset(options.popupOffset);
                    }
                    let content = options.popupContent;
                    if (ev.features[0].properties && typeof content == "string" && !(content in ev.features[0].properties)) {
                        content = item.layer.evalValue("return `" + content + "`", ev.features[0].properties, this.map);
                        if (options.noShowPopup !== true) {
                            popup.setHTML(content);
                        }
                        if (options.clickCallback) {
                            options.clickCallback(content);
                        }
                    } else {
                        ev.features[0].properties = ev.features[0].properties || {}
                        if (!content) {
                            content = ev.features[0].properties;
                        } else {
                            // 如果content是对象的属性,则获取对象的属性值
                            if (content in ev.features[0].properties) {
                                content = ev.features[0].properties[content];
                                try {
                                    // 如果content是json字符串,则尝试转换为对象
                                    content = JSON.parse(content);
                                } catch (e) {}
                            }
                        }
                        if (options.noShowPopup !== true) {
                            const dom = this.context.ui.createElementByJsonData(content, options.popupShowInForm, {
                                width: options.popupWidth,
                                height: options.popupHeight
                            })
                            popup.setDOMContent(dom.element)
                        }
                        if (options.clickCallback) {
                            options.clickCallback(content);
                        }
                    }
                    if (options.noShowPopup !== true) {
                        popup.setLngLat(pt);
                        popup.addTo(this.map);
                    }
                });
            }
        }
    

    /**
     * 获取地图元数据
     * @param {object | object[]} options 参数 可选。
     * @param {string} [options.mapid] 地图ID. 可选,为空时则获取当前打开的mapid
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本).
     * @returns {Promise<Object>} 返回地图元数据, 如果失败则返回undefined, 返回字段如下:
     * @example
      * // 获取地图sys_hello的元数据
      * let res = await this.metadata({
      * mapid: "sys_hello"
      * });
     */
    async metadata(options)  {
            let svc = this.map.getService();
            options = options || {};
            let res =  await svc.metadata(options.mapid, options.version);
            if (res) {
                res.bounds = vjmap.GeoBounds.fromString(res.bounds).toArray();
                res.dbBounds = vjmap.GeoBounds.fromString(res.dbBounds).toArray();
                res.drawBounds = vjmap.GeoBounds.fromString(res.drawBounds).toArray();
                res.initBounds = vjmap.GeoBounds.fromString(res.initBounds).toArray();
                if (res.clipbounds) {
                    res.clipbounds = vjmap.GeoBounds.fromString(res.clipbounds).toArray();
                } else {
                    res.clipbounds = null;
                }
                res.layouts = res.layouts.split(", ");
            }
            return res;
         }
    

    /**
     * 根据json数据弹出数据信息框
     * @param {object|Array} json json数据内容,json对象或数组, 必填
     * @param {boolean} showForm 是否以表单格式显示,参数可选,默认false
     * @param {string} title 对话框标题,参数可选
     * @example
      * // 示例一
      * // 获取地图的当前中心点坐标X和Y、地图级别,生成json对象,根据这数据弹出数据信息框,标题为"地图信息",以表单格式显示
      * let center = this.getCenter();
      * const mapInfo = {
      * centerX: center[0],
      * centerY: center[1],
      * zoom: map.getZoom()
      * }
      * await this.showDataInfoDialog(mapInfo, true, "地图信息");
      * // 示例二
      * // 矩形选择图中实体对象,根据选择的实体数据弹出数据信息框,标题为"实体信息",信息框关闭后清除所有选择的实体对象
      * const geojson1 = await this.selectFeatures({
      * isPointSel: true
      * });
      * await this.showFormInputDialog(geojson1, false, "实体信息");
      * // 清除所有选择的实体对象
      * this.clearSelectedFeatures();
     */
    async showDataInfoDialog(json, showForm, title)  {
            return await this.context.ui.showInfoDlg(json, showForm, title)
        }
    

    /**
     * 获取一个点到多条线的最近点
     * @param {[number, number]} point 点坐标[x,y]
     * @param {[number, number][][] | geojson} lines 多条线的坐标数组,每个元素是一个包含两个数字的数组[x,y] 或 geojson
     * @returns {object} 返回包含最近点、最近点距离、最近点索引、最近点前一个点距离的object, 具体属性如下:
     * @example
      * // 获取一个点到多条线的最近点, 点坐标[130,140], 多条线坐标[[[100,100],[200,200]],[[100,200],[200,100]]]
      * let lines = [
      * [[100, 100], [200, 200]],
      * [[100, 200], [200, 100]]
      * ];
      * let point = [130, 140];
      * let res = this.closestPointOnPolylines(point, lines);
      * console.log(res);
     */
    closestPointOnPolylines(point, lines)  {
            if (lines && lines.type === "FeatureCollection" && lines.features.length > 0) {
                let geojsonLines = [];
                for(let i = 0; i < lines.features.length; i++) {
                    if (lines.features[i].geometry.type === "LineString") {
                        geojsonLines.push(lines.features[i].geometry.coordinates);
                    } else if (lines.features[i].geometry.type === "MultiLineString") {
                        lines.features[i].geometry.coordinates.forEach(ln => geojsonLines.push(ln));
                    }
                }
                lines = geojsonLines;
            }
            if (Array.isArray(lines)) {
                lines = lines.map(line => line.map(co => vjmap.geoPoint(co)));
            }
            // 计算与所有线的最近点
            const res = vjmap.closestPointOnPolylines(vjmap.geoPoint(point), lines);
            if (res && res.closestPoint) {
                res.closestPoint = [res.closestPoint.x, res.closestPoint.y];
            }
            return res;
        }
    

    /**
     * 设置绘制图元属性
     * @param {string} id 图元ID,参数必填
     * @param {object} options 配置参数, 参数可选
     * @param {string} options.color 颜色,格式为#RRGGBB,参数可选
     * @param {string} options.borderColor 边框颜色,格式为#RRGGBB,参数可选
     * @param {number} options.opacity 透明度,参数可选
     * @param {number} options.borderOpacity 边框透明度,参数可选
     * @param {number} options.width 线宽,参数可选
     * @param {number} options.extrusionHeight 拉伸高度,多边形有效,参数可选
     * @param {boolean} options.isOff 是否隐藏, false显示,true隐藏,参数可选
     * @param {boolean} options.isLocked 是否锁定, false不锁定,true锁定,参数可选
     * @param {string} options.text 文本内容, 符号文本有效,参数可选
     * @param {[number, number][] | [number, number]} options.coordinates 坐标点数组,参数可选
     * @param {number} options.data 数据值,参数可选
     * @returns {Promise<Object | undefined>} 返回绘制的图元对象,如果取消操作则返回undefined,返回的对象包含以下属性:
     * @example
      * // 示例一
      * // 选择绘制的图元,把颜色改为红色
      * let geojson = await this.actionSelect();
      * for(let feature of geojson.features) {
      * this.setFeatureProperty(feature.id, {
      * color: "#FF0000",
      * });
      * };
      * // 示例二
      * // 获取绘制的全部图元的第二个实体,设置颜色为黄色,透明度0.6,线宽2,边框颜色为红色
      * let geojson2 =  this.getDrawAll();
      * let features = geojson2.features;
      * let index = 2; // 第二个实体
      * if (index >= features.length) {
      * return;
      * }
      * let feature = features[index];
      * this.setFeatureProperty(feature.id, {
      * color: "#FFFF00",
      * opacity: 0.6,
      * width: 2,
      * borderColor: "#FF0000",
      * });
     */
    setFeatureProperty(id, options)  {
            options = options || {};
            let draw = this.map.getDrawLayer();
            let attr = {
                "color": options.color,// 颜色
                "opacity": options.opacity, // 透明度
                "outlineColor": options.borderColor,// 边框颜色
                "line_width": options.width, // 线宽
                "line_opacity": options.borderOpacity, // 透明度
                "data": options.data,
                "coordinates": options.coordinates,
                "isOff": options.isOff,
                "isLocked": options.isLocked,
                "text": options.text,
                "extrusionHeight": options.extrusionHeight,
            };
    
            for(let key in attr) {
                if (attr[key] !== undefined && attr[key] !== null) {
                    draw.setFeatureProperty(
                        id,
                        key,
                        attr[key]
                    );
                }
            }
            draw.forceRefresh();
        }
    

    /**
     * 创建背景图层
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.backgroundColor 背景颜色,参数可选,支持十六进制颜色值,默认为"#572782"
     * @param {number} options.backgroundOpacity 背景透明度,参数可选,取值范围0-1,默认为0.6
     * @param {string} options.backgroundPattern 背景图案,参数可选,填充图片名称,图片需要预先加载到地图中图像宽度必须是2的系数(2、4、8、...、512)
     * @param {boolean} options.visible 图层是否可见,参数可选,默认为true
     * @param {string} options.before 图层在指定图层之前绘制,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 创建背景图层,背景颜色为#572782,背景透明度为0.6
      * let layer = await this.createBackgroundLayer({
      * backgroundColor: "#572782",
      * backgroundOpacity: 0.6,
      * });
      * console.log(layer);
     */
    async createBackgroundLayer(options)  {
            options = options || {};
            let type = "background";
    
            let randomId = vjmap.RandomID();
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                backgroundColor: "#572782",
                backgroundOpacity: 0.6,
                ...options,
                type: type
            }
           
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId: undefined, layerName, data: undefined, options, layer, visible: true, create: this.createBackgroundLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId: undefined,
                layerId,
                layerName
            };
        }
    

    /**
     * 清空地图数据
     * @param {object} options 选项
     * @param {boolean} [options.clearMarkers] 是否清空所有点标注
     * @param {boolean} [options.clearDraw] 是否清空所有绘制图层
     * @param {boolean} [options.clearOtherLayerData] 清空地图除底图外所有数据
     * @param {boolean} [options.clearAllData] 清空地图所有数据
     * @example
      * // 示例一
      * // 清空地图所有点标注数据
      * this.clearMapData({clearMarkers: true});
      * // 示例二
      * // 清空地图所有绘制图层数据
      * this.clearMapData({clearDraw: true});
      * // 示例三
      * // 清空地图除底图外所有数据
      * this.clearMapData({clearOtherLayerData: true});
      * // 示例四
      * // 清空地图所有数据
      * this.clearMapData({clearAllData: true});
     */
    clearMapData(options)  {
            options = options || {};
            if (options.clearMarkers === true) {
                this.map.removeMarkers();
                this.map.removePopups();
            }
            if (options.clearDraw === true) {
                let drawLayer = this.map.getDrawLayer();
                drawLayer.deleteAll();
            }
            if (options.clearOtherLayerData === true) {
                this.map.removeMarkers();
                this.map.removePopups();
                // 把所有绘图图层删除了
                // @ts-ignore
                const controls = this.map._controls;
                for(let k = controls.length - 1; k >= 0; k--) {
                    if (controls[k] instanceof vjmap.Draw.Tool) {
                        this.map.removeControl(controls[k])
                    }
                }
                let sources = this.map.getStyle().sources;
                
                for(let item in sources) {
                    if (item != "highlight-source" && sources[item].type == "geojson")
                    {
                        // 只是把类型为geojson的移除了。同时点击高亮的图层不要删除了
                        this.map.removeSourceEx(item);
                    }
                }
            } 
            if (options.clearAllData === true) {
                if (this.map.hasVectorLayer()) {
                    this.map.disableVectorLayerHoverHighlight()
                } else {
                    this.map.disableLayerClickHighlight();
                }
                // 把所有绘图图层删除了
                // @ts-ignore
                const controls = this.map._controls;
                for(let k = controls.length - 1; k >= 0; k--) {
                    if (controls[k] instanceof vjmap.Draw.Tool) {
                        this.map.removeControl(controls[k])
                    }
                }
                let sources = this.map.getStyle().sources;
                for(let item in sources) {
                    // @ts-ignore
                   this.map.removeSourceEx(item);
                }
                this.map.removeMarkers();
                this.map.removePopups();
            }
        }
    

    /**
     * 创建箭头线数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.lineColor 线条颜色,默认#FF9900
     * @param {number} options.lineWidth 线宽,默认10
     * @param {number} options.lineOpacity 线透明度,取值0-1
     * @param {number} options.lineGapWidth 线间隙宽度,在线的实际路径之外绘制描边时的内部间隙宽度
     * @param {number} options.lineOffset 线的偏移量,正值向右偏移,负值向左偏移
     * @param {number} options.lineBlur 线模糊度,需小于线宽度
     * @param {string} options.strokeStyle 线型,'solid'实线或'dashed'虚线
     * @param {[number,number]} options.lineDasharray 虚线样式,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,格式[x,y],负数分别表示左和上
     * @param {string} options.lineCap 线帽形状,'butt'尖头、'round'圆头、'square'平头
     * @param {string} options.lineJoin 拐角形状,'bevel'平拐、'round'圆拐、'miter'棱拐
     * @param {string} options.strokeImage 线图案,需与预加载的图片名对应
     * @param {string} options.lineGradient 线渐变
     * @param {boolean} options.showBorder 是否显示线边框,默认true
     * @param {string} options.borderColor 边框颜色,默认#f00
     * @param {number} options.borderWidth 边框宽度
     * @param {number} options.borderOpacity 边框透明度,取值0-1
     * @param {number} options.borderGapWidth 边框间隙宽度
     * @param {number} options.borderOffset 边框偏移量
     * @param {number} options.borderBlur 边框模糊度
     * @param {string} options.borderGradient 边框渐变
     * @param {boolean} options.showDir 是否显示箭头,默认true
     * @param {number} options.dirSize 箭头大小
     * @param {number} options.dirSpacing 箭头间距
     * @param {number} options.dirImageWidth 箭头图像宽度
     * @param {number} options.dirImageHeight 箭头图像高度
     * @param {string} options.dirImageColor 箭头图像颜色
     * @param {string} options.dirIconColor 箭头图标颜色
     * @param {string} options.dirLayout 箭头布局
     * @param {string} options.cursor 鼠标光标形状
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer5的箭头线数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createArrowLineLayer(geojson, {
      * layerName: 'layer5'
      * });
      * console.log(layer);
     */
    async createArrowLineLayer(data, options)  {
            options = options || {};
            let type = "arrowLine";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                lineWidth: 10,
                showDir: true,
                showBorder: true,
                borderColor: "#f00",
                lineColor: '#FF9900',
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createArrowLineLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建动画符号数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.animateImagesType 动画类型,可选值:"arrow"(箭头动画), "antpath"(蚂蚁线动画), "customImage"(自定义图片), "imageSprites"(同一个图片精灵动画集)
     * @param {string} options.animateImages_arrowFillColor 箭头填充颜色,当animateImagesType为"arrow"时有效,默认"#22B14C"
     * @param {string} options.animateImages_arrowStrokeColor 箭头边框颜色,当animateImagesType为"arrow"时有效,默认"#fff"
     * @param {number} options.animateImages_arrowStrokeWidth 箭头线宽,当animateImagesType为"arrow"时有效
     * @param {number} options.animateImages_arrowWidth 箭头大小,当animateImagesType为"arrow"时有效
     * @param {string} options.animateImages_fillColor1 蚂蚁线填充颜色1,当animateImagesType为"antpath"时有效
     * @param {string} options.animateImages_fillColor2 蚂蚁线填充颜色2,当animateImagesType为"antpath"时有效
     * @param {string} options.customImageUrl 自定义图片URL或base64,当animateImagesType为"customImage"时有效
     * @param {string} options.imageSpriteUrl 图片动画集URL或base64,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteWidth 来源图片中精灵图所占宽度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_spriteHeight 来源图片中精灵图所占高度,当animateImagesType为"imageSprites"时有效
     * @param {number} options.animateImages_canvasWidth 画布宽度,除animateImages类型外的所有动画类型通用
     * @param {number} options.animateImages_canvasHeight 画布高度,除animateImages类型外的所有动画类型通用
     * @param {number} options.animateImages_frameCount 动画帧数,除animateImages类型外的所有动画类型通用
     * @param {boolean} options.animateImages_directionReverse 动画方向是否反向,除animateImages类型外的所有动画类型通用
     * @param {number} options.speed 动画速度,步长0.1
     * @param {boolean} options.startAutoAnimation 是否开始时自动播放动画
     * @param {string} options.symbolPlacement 符号放置位置,可选值:"point"(几何图形点上),"line"(几何图形直线上),"line-center"(几何图形线中心)
     * @param {number} options.symbolSpacing 两个符号中心点之间的距离,单位像素,默认250
     * @param {boolean} options.symbolAvoidEdges 符号是否避免碰撞,默认false
     * @param {string} options.symbolZOrder 重叠符号顺序,可选值:"auto","viewport-y","source"
     * @param {string} options.iconImage 图标名称,用于绘制图像背景
     * @param {number} options.iconRotate 图标旋转角度,默认0
     * @param {[number, number]} options.iconOffset 图标与锚点偏移距离,默认[0,0]
     * @param {string} options.iconAnchor 图标锚定位置,可选值:"center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"
     * @param {string} options.iconRotationAlignment 图标旋转对齐,可选值:"map","viewport","auto"
     * @param {string} options.iconPitchAlignment 地图倾斜时图标方向,可选值:"map","viewport","auto"
     * @param {boolean} options.iconAllowOverlap 图标是否允许重叠,默认false
     * @param {number} options.iconOpacity 图标透明度,0-1之间,默认1
     * @param {boolean} options.iconIgnorePlacement 图标是否忽略碰撞,默认false
     * @param {boolean} options.iconOptional 图标重叠选项,默认false
     * @param {number} options.iconSize 图标缩放大小,默认1
     * @param {string} options.iconTextFit 图标适应文本,可选值:"none","width","height","both"
     * @param {[number,number,number,number]} options.iconTextFitPadding 图标文本匹配padding,默认[0,0,0,0]
     * @param {number} options.iconPadding 图标边界填充大小,默认1
     * @param {boolean} options.iconKeepUpright 图标是否防止颠倒呈现,默认false
     * @param {string} options.iconColor SDF图标颜色,默认"#000000"
     * @param {string} options.iconHaloColor SDF图标光圈颜色,默认"rgba(0,0,0,0)"
     * @param {number} options.iconHaloWidth 光圈到图标轮廓距离,默认0
     * @param {number} options.iconHaloBlur 图标光晕模糊宽度,默认0
     * @param {[number,number]} options.iconTranslate 图标平移距离,默认[0,0]
     * @param {string} options.iconTranslateAnchor 图标平移锚点,可选值:"map","viewport"
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer4的动画符号数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createAnimateSymbolLayer(geojson, {
      * layerName: 'layer4'
      * });
      * console.log(layer);
     */
    async createAnimateSymbolLayer(data, options)  {
            options = options || {};
            let type = "animateSymbol";
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                animateImagesType: "arrow",
                animateImages_arrowFillColor: "#22B14C",
                animateImages_arrowStrokeColor: "#fff",
                animateImages_arrowStrokeWidth: 6,
                animateImages_canvasWidth: 128,
                animateImages_canvasHeight: 32,
                animateImages_arrowWidth: 16,
                animateImages_frameCount: 4,
                animateImages_fillColor1: "#f0fb",
                animateImages_fillColor2: "#0ffb",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createAnimateSymbolLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 删除一个点标记Marker
     * @param {string} id 点标记Marker的id
     * @example
      * this.deleteMarker("marker_1"); // 删除id为marker_1的点标记
     */
    deleteMarker(id)  {
           let markers = this.map.getMarkers();
           let marker = markers.find(m => m.id == id);
           if (marker) {
            let point = this.map.fromLngLat(marker.getLngLat());
            
            let oldOptions = {};
            oldOptions.color = marker._color;
            oldOptions.data = marker.data;
            oldOptions.draggable = marker.isDraggable();
            oldOptions.rotation = marker.getRotation();
    
            if (marker.getPopup()) {
                marker.getPopup().remove();
            }
            marker.remove()
    
           
             // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.addMarker(point, oldOptions);
            });
           }
          
        }
    

    /**
     * 设置地图的最大、最小缩放级别
     * @param {object} options 包含maxZoom和minZoom的对象
     * @param {number} options.maxZoom 要设置的最大缩放级别(可为空)
     * @param {number} options.minZoom 要设置的最小缩放级别(可为空)
     * @example
      * this.setMaxMinZoom({maxZoom: 10}); // 设置最大缩放级别为10
     */
    setMaxMinZoom(options)  {
            options = options || {};
            if (options.maxZoom !== undefined) {
                let oldMaxZoom = this.map.getMaxZoom(); // 获取当前最大缩放级别
                this.map.setMaxZoom(options.maxZoom); // 设置新的最大缩放级别
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.map.setMaxZoom(oldMaxZoom);
                });
            }
            if (options.minZoom !== undefined) {
                let oldMinZoom = this.map.getMinZoom(); // 获取当前最小缩放级别
                this.map.setMinZoom(options.minZoom); // 设置新的最小缩放级别
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.map.setMinZoom(oldMinZoom);
                });
            }
        }
    

    /**
     * 测量距离
     * @example
      * // 测量距离
      * await this.measureDistance();
     */
    measureDistance()  {
                vjcommon.runMeasureCmd(this.map, "measureDist");
            }
    
    

    /**
     * 设置点标记Marker的属性
     * @param {string} id 点标记Marker的id
     * @param {Record<string, any>} options 其他参数,参数可选
     * @param {[number, number]} options.position 坐标[x, y],参数可选,默认为undefined
     * @param {string} options.color 颜色,参数可选,默认为#3FB1CE
     * @param {any} options.popupContent 弹窗内容,参数可选,默认为空表示不显示弹窗
     * @param {boolean} options.popupShowInForm 弹窗内容是否以表单形式显示,参数可选,默认为false
     * @param {number} options.popupWidth 弹窗宽度,参数可选
     * @param {number} options.popupHeight 弹窗高度,参数可选
     * @param {boolean} options.popupOpen 弹窗内容是否打开,参数可选,默认为false
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {number} options.rotation 旋转角度,参数可选,默认为0
     * @param {string} options.icon 自定义图标名称,参数可选,默认为空
     * @param {any} options.data 数据内容,参数可选,默认为undefined
     * @param {number} options.elevation 坐标标高值,参数可选,默认为0
     * @param {boolean} options.visible 是否显示,参数可选,默认为true
     * @example
      * // 设置id为marker_1的点标记的属性,坐标为[10, 20],颜色为红色,弹窗内容为"Hello, World!",图标为sensor,可拖动,旋转角度为45度,数据内容为{name: "Sensor", value: 100}
      * this.setMarkerProperty("marker_1", {
      * position: [10, 20],
      * color: "#FF0000",
      * popupContent: "Hello, World!",
      * icon: "sensor",
      * draggable: true,
      * rotation: 45,
      * data: {name: "Sensor", value: 100}
      * });
     */
    setMarkerProperty(id, options)  {
            let markers = this.map.getMarkers();
            let marker = markers.find(m => m.id == id);
            let oldOptions = {};
            if (marker) {
                if (options.position) {
                    let position = this.map.fromLngLat(marker.getLngLat());
                    oldOptions.position = [position.x, position.y];
                    marker.setLngLat(this.map.toLngLat(options.position));
                }
                if (options.color) {
                    oldOptions.color = marker._color;
                    marker.setColor(options.color);
                }
                if (options.data !== undefined) {
                    oldOptions.data = marker.data;
                    marker.data = options.data;
                }
                if (options.elevation) {
                    oldOptions.elevation = marker.getHeight();
                    marker.setHeight(options.elevation);
                }
                if (options.popupContent) {
                    let popup = marker.getPopup();
                    if (!popup) {
                        popup = new vjmap.Popup({
                            offset: options.popupOffset || [0, -40]
                        })
                        marker.setPopup(popup)
                    }
                    const dom = this.context.ui.createElementByJsonData(options.popupContent, options.popupShowInForm, {
                        width: options.popupWidth,
                        height: options.popupHeight
                    })
                    popup.setDOMContent(dom.element)
                }
                if (options.popupOpen !== undefined) {
                    let popup = marker.getPopup();
                    if (popup) {
                        if (popup.isOpen() && !options.popupOpen) {
                            marker.togglePopup()
                        } else if (!popup.isOpen() && options.popupOpen) {
                            marker.togglePopup()
                        }
                    }
                }
                if (options.icon) { 
                    // 获取自定义图标数据, 在工具栏中的"地图图像管理"中对自定义图标进行管理
                    let image = this.context.ui.getCustomImages(options.icon);
                    if (image) {
                        let el = marker.getElement();
                        if (el) {
                            el.className = 'marker';
                            let imgValue = image.value;
                            if (imgValue.toLowerCase().indexOf("<svg") == 0) {
                                //svg或base64 png
                                imgValue =  "data:image/svg+xml;base64," + window.btoa(unescape(encodeURIComponent(imgValue))) ;
                            }
                            el.style.backgroundImage =
                            `url("${imgValue}")`;
                            el.style.width = (image.width ?? 40) + 'px';
                            el.style.height = (image.height ?? 40) + 'px';
                            el.style.backgroundSize = '100%';
                        }
                    }
                }
                if (options.draggable) {
                    oldOptions.draggable = marker.isDraggable();
                    marker.setDraggable(options.draggable);
                }
                if (options.rotation) {
                    oldOptions.rotation = marker.getRotation();
                    marker.setRotation(options.rotation);
                }
                if (options.visible !== undefined) {
                    oldOptions.visible = marker.getElement().style.display !== 'none';
                    marker.setVisible(options.visible, true);
                }
               
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.setMarkerProperty(id, oldOptions);
            });
            
         }
    

    /**
     * 创建文本数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {Object} options.style 文本样式设置,参数可选
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {string} options.color 标记颜色,参数可选,默认为'#3FB1CE'
     * @param {number[]} options.offset 偏离XY像素值,如[0,0],负数表示向左和向上
     * @param {number} options.rotation 标记旋转角度,顺时针旋转,默认0
     * @param {string} options.anchor 标记锚点位置,可选值:center、top、bottom、left、right、top-left、top-right、bottom-left、bottom-right,默认center
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型:MAP_ANIMATION_NONE(无动画)、MAP_ANIMATION_BOUNCE(弹跳)、MAP_ANIMATION_DROP(坠落)
     * @param {string} options.rotationAlignment 旋转对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {string} options.pitchAlignment 倾斜对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {number} options.scale 缩放比例,默认1,对应高度41px宽度27px
     * @param {number} options.scaleMaxZoom 能缩放的最大级别(0-24),小于此级别时自动缩放
     * @param {number} options.height 标高值,单位CAD图制图单位
     * @param {boolean} options.removeWhenNoInMapView 是否在视图范围内自动显隐
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐的padding像素值,默认500
     * @param {number} options.clickTolerance 点击像素容差,默认继承地图的clickTolerance
     * @param {string} options.customImage 自定义图片地址/base64/svg内容
     * @param {number} options.customImageWidth 自定义图片宽度
     * @param {number} options.customImageHeight 自定义图片高度
     * @param {string} options.customHtml 自定义Html元素的JS代码
     * @param {string} options.popupHtml 信息窗口HTML内容
     * @param {[number,number]} options.popupOffset 信息窗口偏离XY像素值
     * @param {string} options.popupAnchor 信息窗口锚点位置,同anchor参数
     * @param {boolean} options.closeButton 是否显示关闭按钮
     * @param {boolean} options.closeOnClick 是否在点击地图时关闭弹出窗口
     * @param {boolean} options.closeOnMove 是否在地图移动后关闭信息窗口
     * @param {boolean} options.focusAfterOpen 是否尝试聚焦弹出窗口内第一个可聚焦元素
     * @param {string} options.className 添加到弹出容器的CSS类名
     * @param {string} options.maxWidth 弹出窗口最大宽度,CSS属性字符串,默认'240px'
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer27的文本数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createTextDataLayer(geojson, {
      * layerName: 'layer27'
      * });
      * console.log(layer);
     */
    async createTextDataLayer(data, options)  {
            options = options || {};
            let type = "text";
        
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                style: {
                    'cursor': 'pointer',
                    'opacity': 1,
                    'padding': '12px',
                    'border-radius': '4px',
                    'background-color': '#0ff',
                    'border-width': 0,
                    'box-shadow': '0px 2px 6px 0px rgba(97,113,166,0.2)',
                    'text-align': 'center',
                    'font-size': '14px',
                    'color': '#F33'
                },
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createTextDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建点标记聚合数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {string} options.color 标记颜色,参数可选,默认为'#3FB1CE'
     * @param {number[]} options.offset 偏离XY像素值,如[0,0],负数表示向左和向上
     * @param {number} options.rotation 标记旋转角度,顺时针旋转,默认0
     * @param {string} options.anchor 标记锚点位置,可选值:center、top、bottom、left、right、top-left、top-right、bottom-left、bottom-right,默认center
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型:MAP_ANIMATION_NONE(无动画)、MAP_ANIMATION_BOUNCE(弹跳)、MAP_ANIMATION_DROP(坠落)
     * @param {string} options.rotationAlignment 旋转对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {string} options.pitchAlignment 倾斜对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {number} options.scale 缩放比例,默认1,对应高度41px宽度27px
     * @param {number} options.scaleMaxZoom 能缩放的最大级别(0-24),小于此级别时自动缩放
     * @param {number} options.height 标高值,单位CAD图制图单位
     * @param {boolean} options.removeWhenNoInMapView 是否在视图范围内自动显隐
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐的padding像素值,默认500
     * @param {number} options.clickTolerance 点击像素容差,默认继承地图的clickTolerance
     * @param {string} options.customImage 自定义图片地址/base64/svg内容
     * @param {number} options.customImageWidth 自定义图片宽度
     * @param {number} options.customImageHeight 自定义图片高度
     * @param {string} options.customHtml 自定义Html元素的JS代码
     * @param {string} options.popupHtml 信息窗口HTML内容
     * @param {[number,number]} options.popupOffset 信息窗口偏离XY像素值
     * @param {string} options.popupAnchor 信息窗口锚点位置,同anchor参数
     * @param {boolean} options.closeButton 是否显示关闭按钮
     * @param {boolean} options.closeOnClick 是否在点击地图时关闭弹出窗口
     * @param {boolean} options.closeOnMove 是否在地图移动后关闭信息窗口
     * @param {boolean} options.focusAfterOpen 是否尝试聚焦弹出窗口内第一个可聚焦元素
     * @param {string} options.className 添加到弹出容器的CSS类名
     * @param {string} options.maxWidth 弹出窗口最大宽度,CSS属性字符串,默认'240px'
     * @param {boolean} options.allowOverlap 是否允许标记重叠
     * @param {number} options.allowOverlapMaxZoom 允许重叠的最大缩放级别,小于或等于此级别才会处理重叠,超过此级时会全部显示,默认4级
     * @param {number} options.markerWidth marker div的像素宽,用于计算重叠时需要,默认40
     * @param {number} options.markerHeight marker div的像素高,用于计算重叠时需要,默认40
     * @param {Object} options.textStyle 聚合文本的CSS样式对象,如{cursor:"pointer", opacity:0.8等}
     * @param {Array<Array>} options.textColors 聚合文本颜色配置,格式为[[值1,文本颜色,背景色], [值2,文本颜色,背景色], ...]
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer20的点标记聚合数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createMarkerClusterLayer(geojson, {
      * layerName: 'layer20'
      * });
      * console.log(layer);
     */
    async createMarkerClusterLayer(data, options)  {
            options = options || {};
            let type = "markerCluster";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                textStyle: {
                  cursor: "pointer",
                  opacity: 0.8,
                  padding: "6px",
                  "border-radius": "12px",
                  "border-width": 0,
                  "box-shadow": "0px 2px 6px 0px rgba(97,113,166,0.2)",
                  "text-align": "center",
                  "font-size": "14px",
                },
                textColors: [
                    [0, "#00FFFF", "#00FFFF"],
                    [5, "#F0F", "#80FF00"],
                    [10, "#00F", "#FFFF00"],
                    [1000, "#FFF", "#FF3D3D"]
                ],
                popupHtml: "<h3 style='color:red'>index ${props.index}</h3>",
                popupOffset: [0, -28],
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createMarkerClusterLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 处理图形组合生成新地图
     * @param {object | object[]} options 参数 可选。可以是一个对象或对象数组。如果是对象,属性值是以下参数说明中的。如果是数组,每项的内容和对象的内容是一样的。
     * @param {string} [options.mapid] 地图ID. 可选,为空时则获取当前打开的mapid
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本). 可选
     * @param {[number, number, number, number]} [options.clipbounds] 地图裁剪范围,范围如[x1,y1,x2,y2],为空的话,表示不裁剪. 可选
     * @param {boolean} [options.selByCrossing] 选择是包含还是相交(默认false表示包含,true相交). 可选
     * @param {[number, number, number, number]} [options.fourParameter] 四参数(x偏移,y偏移,缩放,旋转弧度),可选,对坐标最后进行修正. 可选
     * @param {boolean} [options.isInverseFourParamter] 是否用上面的四参数进行反算,默认false. 可选
     * @param {string[]} [options.layers] 要显示的图层名称,为空的时候,表示全部图层. 可选
     * @param {boolean} [options.purge] 生成后清理图形数据以减少dwg文件大小. 可选
     * @param {boolean} [options.isZoomExtents] 是不是创建完缩放至全图 默认false (如果有多个图合并,只需设置第一个图的). 可选
     * @param {string | "*" | "cad2000" | "cad2004" | "cad2007" | "cad2010" | "cad2013" | "cad2018"} [options.cadVersion] 导出的CAD版本号。如果为*表示为当前CAD图的版本. 可选
     * @returns {Promise<string|undefined>} 返回生成的fileid, 如果失败则返回undefined
     * @example
      * //示例一
      * // 处理图形组合生成新地图, 要显示的图层列表为["0"]
      * let res = await this.composeNewMap({
      * layers: ["0"]
      * });
      * if (res) {
      * this.showMessage("生成新地图成功,fileid为" + res, "success");
      * }
      * //示例二
      * // 把mapid为sys_hello和sys_world的地图处理图形组合生成新地图
      * let res2 = await this.composeNewMap([{
      * mapid: "sys_hello"
      * }, {
      * mapid: "sys_world"
      * }]);
      * if (res2) {
      * this.showMessage("生成新地图成功,fileid为" + res2, "success");
      * }
     */
    async composeNewMap(options)  {
            let svc = this.map.getService();
            options = options || {};
            let currentMap = svc.currentMapParam() || {};
            if (Array.isArray(options)) {
               for(let opt of options) {
                if (!opt.mapid) {
                    opt.mapid = currentMap.mapid;
                }
               }
            } else {
                if (!options.mapid) {
                    options.mapid = currentMap.mapid;
                }
            }
            let res = await svc.composeNewMap(options);
            if (res && res.error) {
                this.showMessage(res.error)
                return;
            }
            return res.fileid;
        }
    

    /**
     * 创建线拉伸图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.fillExtrusionColor 拉伸颜色,参数可选,默认为"#00ffff"
     * @param {number} options.fillExtrusionOpacity 透明度,参数可选,取值范围0-1
     * @param {number} options.fillExtrusionHeight 拉伸CAD图制图单位,参数可选,默认为500000
     * @param {number} options.fillExtrusionBase 拉伸底部高度,单位CAD图制图单位,参数可选,默认为0
     * @param {string} options.fillExtrusionPattern 拉伸填充图案,参数可选,使用雪碧图中的图像名称,图像宽度必须是2的系数
     * @param {[number,number]} options.fillExtrusionTranslate 平移量,参数可选,格式[x,y],负数表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillExtrusionTranslateAnchor 平移参考系,参数可选,"map"表示相对地图平移,"viewport"表示相对视窗平移
     * @param {boolean} options.fillExtrusionVerticalGradient 是否应用垂直渐变,参数可选,true时侧面下方位置会略暗
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {number} options.offsetLine 线扩展大小,参数可选,默认为10
     * @param {boolean} options.isBreakLine 是否打散成线段,参数可选
     * @param {number} options.anmiDuration 动画持续时长,单位秒,参数可选,默认为0(表示没有动画)
     * @param {number} options.anmiRepeat 动画重复次数,参数可选,默认为0(表示无限循环)
     * @param {string} options.anmiRepeatType 动画重复类型,参数可选,可选值:"reverse"(反向)、"loop"(循环)、"mirror"(镜像)
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer18的线拉伸数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createLineExtrusionsLayer(geojson, {
      * layerName: 'layer18'
      * });
      * console.log(layer);
     */
    async createLineExtrusionsLayer(data, options)  {
            options = options || {};
            let type = "lineExtrusions";
        
            if(options.fillExtrusionHeight) {
              options.fillExtrusionHeight = this.map.geoLengthToHeight(options.fillExtrusionHeight);
            }
            if(options.fillExtrusionBase) {
              options.fillExtrusionBase = this.map.geoLengthToHeight(options.fillExtrusionBase);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillExtrusionColor: "#00ffff",
                fillExtrusionHeight: this.map.geoLengthToHeight(this.map.getGeoBounds().width() / 6),
                anmiDuration: 0,
                offsetLine: 10,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createLineExtrusionsLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 叠加CAD图
     * @param {string} [options.mapid] 地图ID
     * @param {string} [options.version] 地图版本(为空时采用当前打开的地图版本)
     * @param {string} [options.layer] 图层样式名称(如果为空时,则用默认样式)
     * @param {string} [options.epsg] cad图epsg代号
     * @param {"beijing54"|"xian80"|"cgs2000"} [options.crs] cad图的坐标系,beijing54(北京54坐标)、xian80(西安80坐标、cgs2000(CGCS2000坐标)
     * @param {string} [options.webMapTiles] 叠加地图为互联网地图时,数据瓦片地址, 可为空
     * @param {boolean} [options.overMapImage] 叠加地图为互联网地图时,是否为影像地图
     * @param {boolean} [options.isSetRotateZero] 公共点叠加时是否允许旋转
     * @param {boolean} [options.baseMapWgs84] 底图是否为互联网地图wgs84坐标
     * @returns {Promise<string>} 返回叠加的图层名称
     * @example
      * // 示例一
      * // 叠加cad图,mapid为sys_world
      * let layerName = await this.overlayCadMap({
      * mapid: "sys_world"
      * });
      * console.log("layerName", layerName);
      * // 示例二
      * // 自动叠加cad图,mapid为sys_cad2000
      * let layerName2 = await this.overlayCadMap({
      * mapid: "sys_cad2000",
      * overlayType: "auto"
      * });
      * console.log("layerName2", layerName2);
      * // 示例三
      * // 直接叠加cad图,mapid为sys_world
      * let layerName3 = await this.overlayCadMap({
      * mapid: "sys_world",
      * overlayType: "direct"
      * });
      * console.log("layerName3", layerName3);
     */
    async overlayCadMap(options)  {
            options = {...options}
            // 判断底图是否为互联网地图
            let isWebMap = this.map.getMapProjection() instanceof vjmap.LnglatProjection;
            let wmsTileUrl;
            if (!options.mapid) {
                this.showMessage("请设置要叠加的cad图的mapid");
                return;
            }
            if (isWebMap) {
               // 底图是互联网地图,互联网地图叠加cad图, 只能自动叠加或四参数叠加
                let epsg = options.epsg;
                if (!epsg) {
                    epsg = await this.getCadEpsgCode(options);
                }
                if (options.overlayType !== "param" && epsg) {
                    options.epsg = epsg;
                   // 自动叠加
                   wmsTileUrl = await this.getWmsTileUrl(options);
                   let svc = this.map.getService();
                   // 把cad图的坐标转成互联网地图的坐标,把地图移动到cad图的中心点
                   const cadToWebCoordinate = async point => {
                        let result = await svc.cmdTransform(epsg, "EPSG:4326", vjmap.geoPoint(point)); // 如果不想调服务转,也可以在前端用proj4库
                        return result[0];// 返回的第1条结果
                   }
                   let metadata = await svc.metadata(options.mapid, options.version);
                   let mapExtent = vjmap.GeoBounds.fromString(metadata.bounds);
                   let p1 = await cadToWebCoordinate(mapExtent.min);
                   let p2 = await cadToWebCoordinate(mapExtent.max);
                   this.fitMapBounds([p1[0],p1[1],p2[0],p2[1]], {padding: 0}); 
                } else {
                   // 四参数叠加
                    // 用四参数叠加, 左边是默认地图,右边是要叠加的cad图
                    let fp = await this.context.ui.getFourParamter({
                        mapid: options.mapid,
                        version: options.version,
                        layer: options.layer
                    });
                    if (!fp) return;
                    options.coordinates = [];
                    for(let n = 0; n < fp.leftMarkers.length; n++) {
                        let leftMarker = fp.leftMarkers[n];
                        let rightMarker = fp.rightMarkers[n];
                        options.coordinates.push({
                            x1: rightMarker.x,
                            y1: rightMarker.y,
                            x2: leftMarker.x,
                            y2: leftMarker.y
                        });
                    }
                    options.overlayType = "param";
                    options.isSetRotateZero = !fp.allowsRotation;
                    wmsTileUrl = await this.getWmsTileUrl(options);
                    let svc = this.map.getService();
                    // 把cad图的坐标转成互联网地图的坐标,把地图移动到cad图的中心点
                    const cadToWebCoordinate =  point => {
                        let p = vjmap.coordTransfromByFourParamter(point,{
                            dx: fp.fourParamter[0], 
                            dy: fp.fourParamter[1], 
                            scale: fp.fourParamter[2], 
                            rotate: fp.fourParamter[3],
                        });
                        let wgs84 = vjmap.Projection.mercator2LngLat(p); // 墨卡托3857转经纬度wgs84
                        return wgs84;
                    }
                    let metadata = await svc.metadata(options.mapid, options.version);
                    let mapExtent = vjmap.GeoBounds.fromString(metadata.bounds);
                    let p1 =  cadToWebCoordinate(mapExtent.min);
                    let p2 =  cadToWebCoordinate(mapExtent.max);
                    this.fitMapBounds([p1[0],p1[1],p2[0],p2[1]], {padding: 0}); 
                }
            } else {
               // 底图是cad图,cad图叠加cad图,只能直接通过坐标叠加或四参数叠加
               if (options.overlayType == "direct") {
                // 直接通过坐标叠加
                // 自动叠加
                wmsTileUrl = await this.getWmsTileUrl(options);
               } else {
                // 四参数叠加
                // 用四参数叠加, 左边是默认地图,右边是要叠加的cad图
                if (!options.mapid) {
                    this.showMessage("请设置要叠加的cad图的mapid");
                    return;
                }
                let fp = await this.context.ui.getFourParamter({}, {
                    mapid: options.mapid,
                    version: options.version,
                    layer: options.layer
                });
                if (!fp) return;
                options.coordinates = [];
                for(let n = 0; n < fp.leftMarkers.length; n++) {
                    let leftMarker = fp.leftMarkers[n];
                    let rightMarker = fp.rightMarkers[n];
                    options.coordinates.push({
                        x1: leftMarker.x,
                        y1: leftMarker.y,
                        x2: rightMarker.x,
                        y2: rightMarker.y
                    });
                }
                options.overlayType = "param";
                options.overMapType = "CAD";
                options.isSetRotateZero = !fp.allowsRotation;
                wmsTileUrl = await this.getWmsTileUrl(options);
               }
            }
            if (!wmsTileUrl) return;
            // 创建栅格瓦片图层
            let layer = await this.createRasterLayer({
                tiles: wmsTileUrl,
            });
            return layer
          }
    

    /**
     * 删除数据图层
     * @param {string} layerName 图层名称,参数必填
     * @example
      * // 删除图层名称为layer1的数据图层
      * let layerName = 'layer1';
      * this.deleteDataLayer(layerName);
     */
    deleteDataLayer(layerName)  {
            let item = this.context.global.layers.find(layer => layer.layerName == layerName);
            if(item) {
                let layerId = item.layerId;
                let sourceId = item.sourceId;
                if (item.layer && typeof(item.layer.getLayerId) == "function") {
                    layerId = item.layer.getLayerId();
                    let style = this.map.getStyle();
                    let layer = style.layers.find(layer => layer.id == layerId);
                    if (layer && layer.source) {
                        sourceId = layer.source;
                    }
                }
                item.layer.removeLayer(this.map, layerId);
                if (sourceId) {
                    this.map.removeSourceEx(sourceId);
                }
                this.context.global.layers = this.context.global.layers.filter(layer => layer.layerId != item.layerId);
    
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    if (item.create) {
                        item.create(item.data, item.options);
                    }
                });
            }
        }
    

    /**
     * 飞行至目标位置
     * @param {Object} options 缩放选项
     * @param {[number,number]} options.center 目标位置的坐标
     * @param {number} [options.zoom] 目标缩放级别。可选,如果不提供,则保持当前缩放级别
     * @param {number} [options.bearing] 目标方位角(旋转角度),以度为单位,0 表示正北。可选,如果不提供,则保持当前方位角
     * @param {number} [options.pitch] 目标倾斜角度,以度为单位,0 表示垂直于地图。可选,如果不提供,则保持当前倾斜角度
     * @param {number} [options.speed] 飞行速度的倍数。默认值为 1.2。可选
     * @param {number} [options.curve] 飞行路径的曲率,值越大路径越弯曲。默认值为 1.42。可选
     * @param {boolean} [options.essential] 是否为必要动画,如果为true,则不会受到用户设置的“减少运动”选项的影响。可选,默认值为true
     * @param {boolean} [options.useAsync] 是否使用异步动画,如果为true,则使用异步动画。可选,默认值为false
     * @param {boolean} [options.easeTo] 是否使用缓动动画,如果为true,则使用缓动动画。可选,默认值为false
     * @example
      * // 示例一
      * // 飞行至目标位置[100,20]
      * this.flyTo({center: [100,20]});
      * // 示例二
      * // 飞行至目标位置[100,20],缩放级别为10,旋转角度为45度,倾斜角度为60度,使用缓动动画
      * this.flyTo({center: [100,20], zoom: 10, bearing: 45, pitch: 60, easeTo: true});
     */
    async flyTo(options)  {
            options = options || {};
            if (options.center) {
                options.center = this.map.toLngLat(options.center);
            }
            options.essential = options.essential === undefined ? true : options.essential;
            let oldCenter = this.map.getCenter();
            let oldZoom = this.map.getZoom();
            let oldBearing = this.map.getBearing();
            let oldPitch = this.map.getPitch();
            let method = options.easeTo === true ? "easeTo" : "flyTo";
            if (options.useAsync === true) {
                function animateAsync(options) {
                    return new Promise((resolve) => {
                        // 监听地图移动结束事件
                        this.map.once('moveend', ({ originalEvent }) => {
                            if (!originalEvent) {
                                resolve()
                            }
                        });
                        this.map[method](options);
                    });
                }
                await animateAsync(options);
            } else {
                this.map[method](options)
            }
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.setCenter(oldCenter);
                this.map.setZoom(oldZoom);
                this.map.setBearing(oldBearing);
                this.map.setPitch(oldPitch);
            });
         }
    

    /**
     * 在地图范围内随机生成点
     * @param {number} count 要生成的点数,默认1
     * @param {number} boundsType 范围类型(0 地图绘制范围,1 地图实际范围, 2 地图整个范围),默认0, 参数可选
     * @returns {[number, number][]} 返回包含多个坐标点的数组[[x1,y1],[x2,y2],...]
     * @example
      * // 示例一
      * // 在地图的范围内随机生成1个点
      * let points = this.randomPointInMapBounds(1);
      * let x = points[0][0];
      * let y = points[0][1];
      * console.log(x, y);
      * // 示例二
      * // 在地图的实际范围内随机生成10个点
      * let points2 = this.randomPointInMapBounds(10, 1);
      * for (let i = 0; i < points2.length; i++) {
      * let x = points2[i][0];
      * let y = points2[i][1];
      * console.log(x, y);
      * }
     */
    randomPointInMapBounds(count, boundsType)  {
            let rect = this.getMapGeoBounds(boundsType);
            let geoBounds = vjmap.GeoBounds.fromArray(rect);
            let points = geoBounds.randomPoints(count, count);
            return points.map(p => [p.x, p.y]);
        }
    

    /**
     * 切换CAD图层
     * @example
      * // 切换CAD图层
      * this.switchCadLayers();
     */
    async switchCadLayers()  {
            // 先获取默认的图层
            let layers = this.map.getService().getMapLayers();
            let layerNames = layers.map(layer => layer.name);
            let openLayers = layers.filter(layer => layer.isOff === false).map(layer => layer.name);
            const getSelectLayers = (selectNames) => {
                let selectLayers = [];
                for (let layerName of layerNames) {
                    let isOpen = selectNames.includes(layerName);
                    if (isOpen) {
                        selectLayers.push({name: layerName, isOff: false});
                    } else {
                        selectLayers.push({name: layerName, isOff: true});
                    }
                }
                return selectLayers;
            }
            let isClickApply = false;
            let selectLayerNames = await this.selectOptionsValue(layerNames, {
                isMultiSelect: true,
                title: "选择图层",
                initValue: openLayers,
                applyCallback: async (selectNames) => {
                    isClickApply = true;
                    // 点击应用时,也切换图层
                    await vjcommon.switchCadLayers(this.map, getSelectLayers(selectNames), this.map.hasVectorLayer());
                }
            });
            if (!selectLayerNames) {
                if (isClickApply) {
                    // 如果点击了应用,取消时,切换到原来的图层
                    await vjcommon.switchCadLayers(this.map, getSelectLayers(openLayers), this.map.hasVectorLayer());
                }
                return;
            }
            // 切换图层
            await vjcommon.switchCadLayers(this.map, getSelectLayers(selectLayerNames), this.map.hasVectorLayer());
            // 添加撤销记录
            let oldLayers = getSelectLayers(openLayers);
            let isVector = this.map.hasVectorLayer();
            this.context.ui.addUndoRecord(() => {
                vjcommon.switchCadLayers(this.map, oldLayers, isVector);
            });
        }
    
    

    /**
     * 创建多边形拉伸动画数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.fillExtrusionColor 拉伸颜色,参数可选,默认为"#00ffff"
     * @param {number} options.fillExtrusionOpacity 透明度,参数可选,取值范围0-1
     * @param {number} options.fillExtrusionHeight 拉伸高度,单位CAD图制图单位,参数可选,默认为500000
     * @param {number} options.fillExtrusionBase 拉伸底部高度,单位CAD图制图单位,参数可选,默认为0
     * @param {string} options.fillExtrusionPattern 拉伸填充图案,参数可选,使用雪碧图中的图像名称,图像宽度必须是2的系数
     * @param {[number,number]} options.fillExtrusionTranslate 平移量,参数可选,格式[x,y],负数表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillExtrusionTranslateAnchor 平移参考系,参数可选,"map"表示相对地图平移,"viewport"表示相对视窗平移
     * @param {boolean} options.fillExtrusionVerticalGradient 是否应用垂直渐变,参数可选,true时侧面下方位置会略暗
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {number} options.anmiDuration 动画持续时长,单位秒,参数可选,默认为2,值为0表示没有动画
     * @param {number} options.anmiRepeat 动画重复次数,参数可选,值为0表示无限循环
     * @param {string} options.anmiRepeatType 动画重复类型,参数可选,可选值:"reverse"(来回播放)、"loop"(循环播放)、"mirror"(镜像播放)
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer13的多边形拉伸动画数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createFillExtrusionsAnimateLayer(geojson, {
      * layerName: 'layer13'
      * });
      * console.log(layer);
     */
    async createFillExtrusionsAnimateLayer(data, options)  {
            options = options || {};
            let type = "fillExtrusionsAnimate";
        
            if(options.fillExtrusionHeight) {
              options.fillExtrusionHeight = this.map.geoLengthToHeight(options.fillExtrusionHeight);
            }
            if(options.fillExtrusionBase) {
              options.fillExtrusionBase = this.map.geoLengthToHeight(options.fillExtrusionBase);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillExtrusionColor: "#00ffff",
                fillExtrusionHeight: this.map.geoLengthToHeight(this.map.getGeoBounds().width() / 6),
                anmiDuration: 2,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createFillExtrusionsAnimateLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 监听地图事件
     * @param {string} eventName 事件名称,参数必填, 事件名称有:
     * @param {function} callback 事件回调函数,参数必填
     * @param {boolean} isOnce 是否只触发一次,默认false,参数可选
     * @example
      * // 示例一
      * // 监听地图双击事件
      * this.listenMapEvent("dblclick", ev => {
      * console.log(ev);
      * });
      * // 示例二
      * // 监听地图单击事件,只触发一次,在点击的位置增加一个Marker
      * this.listenMapEvent("click", ev => {
      * if (ev && ev.point) {
      * // 获取当前地图的像素坐标,转换为CAD图几何坐标
      * const point =  this.pixelPointToGeoPoint(ev.point);
      * // 根据获取的CAD图几何坐标位置,在地图上增加一个Marker
      * this.addMarker(point);
      * }
      * }, true);
      * // 示例三
      * // 监听地图实体点击事件,通过点击内容显示数据面板,面板标题为"实体数据",面板高度为500,面板以表单形式显示
      * this.listenMapEvent("clickEntity", ev => {
      * if (ev) {
      * this.showDataPanel(ev, { title: "实体数据", height: 500, showForm: true });
      * } else {
      * this.closeDataPanel();
      * }
      * });
     */
    listenMapEvent(eventName, callback, isOnce)  {
            // callback的参数中含有当前地图的像素坐标,可通过 this.pixelPointToGeoPoint(ev.point) 转换为CAD图几何坐标
            
            // 将事件监听器添加到全局对象中,以便在取消监听时使用
            this.context.global._delegatedListeners = this.context.global._delegatedListeners || {};
            this.context.global._delegatedListeners[eventName] = this.context.global._delegatedListeners[eventName] || [];
            this.context.global._delegatedListeners[eventName].push(callback);
    
            if (eventName === "clickEntity") {
                if (this.context.global._delegatedListeners[eventName].length === 1) {
                    // 第一次监听
                    let oldEventValue;
                    this.map.enableLayerClickHighlight(this.map.getService(), e => {
                        if (e !== oldEventValue) {
                            this.context.global._delegatedListeners[eventName].forEach(func => {
                                func(e);
                            });
                            oldEventValue = e;
                        }
                    })
                }
                return;
            } 
    
            if (isOnce) {
                this.map.once(eventName, callback);
            } else {
                this.map.on(eventName, callback);
            }
    
            if (!this.context.global.__listenKeyEvent) {
                // 先主动监听键盘事件,以便获取当前是否按下Shift、Ctrl、Alt键
                this.context.global.__listenKeyEvent = vjcommon.listenKeyEvent()
            }
            
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.map.off(eventName, callback);
                if (this.context.global._delegatedListeners && this.context.global._delegatedListeners[eventName]) {
                    let index = this.context.global._delegatedListeners[eventName].indexOf(callback);
                    if (index !== -1) {
                        this.context.global._delegatedListeners[eventName].splice(index, 1);
                    }
                }
            });
        }
    

    /**
     * 将地图像素点坐标转换为CAD图几何坐标
     * @returns {[number, number]} 返回包含两个数字的数组[x,y],表示CAD图几何坐标
     * @example
      * // 将地图像素点坐标[5, 10]转换为CAD图几何坐标
      * let point = this.pixelPointToGeoPoint([5, 10]);
      * let x = point[0];
      * let y = point[1];
      * console.log(x, y);
     */
    pixelPointToGeoPoint(pt)  {
            let lnglat = this.map.unproject(pt);
            let geoPoint = this.map.fromLngLat(lnglat);
            return [geoPoint.x, geoPoint.y];
        }
    

    /**
     * 给定路线、起始点、终点生成最短路径
     * @param {Object} options 配置参数
     * @param {[number, number]} options.startPoint 起点 [lng, lat]
     * @param {[number, number]} options.endPoint 终点 [lng, lat]
     * @param {number} [options.precision] 误差,小数点后几位,默认为0
     * @param {boolean} [options.hasDirection] 是否考虑方向,默认为false
     * @param {boolean} [options.disableDrawPath] 禁止自动绘制路径,默认为false
     * @param {string} [options.drawPathColor] 绘制路径颜色,默认为"#ff0000"
     * @param {number} [options.drawPathWidth] 绘制路径宽度,默认为5
     * @returns {Object | null} 返回最短路径信息,包括起点、终点、路径和详细路径信息、绘制路径的图层id、绘制路径的图层源id, 如果返回null,则表示没有找到路径, 具体返回参数如下:
     * @example
      * // 给定路线[[116.397428, 39.90923], [116.405285, 39.90923]]、[[116.405285, 39.90923], [116.425285, 39.91923]]、起始点[116.397428, 39.90923]、终点[116.405285, 39.90923]生成最短路径
      * let result = this.findShortestPath({
      * startPoint: [116.397428, 39.90923],
      * endPoint: [116.405285, 39.90923],
      * lines: [
      * {points: [[116.397428, 39.90923], [116.405285, 39.90923]]},
      * {points: [[116.405285, 39.90923], [116.425285, 39.91923]]},
      * ]
      * });
      * console.log(result);
     */
    findShortestPath(options)  {
            options = options || {};
            options.lines = options.lines || [];
            options.lines = options.lines.map(line => {
                return {
                    points: line.points.map(point => vjmap.geoPoint(point)),
                    id: line.id,
                    weight: line.weight
                }
            });
            let result = vjmap.findShortestPath(vjmap.geoPoint(options.startPoint), vjmap.geoPoint(options.endPoint), options.lines, options.precision, options.hasDirection);
        
            if (result.error) {
                this.map.logInfo(result.error.message, "error");
                return null;
            } 
            if (options.disableDrawPath !== true) {
               let polyline = new vjmap.Polyline({
                    data: this.map.toLngLat(result.route),
                    lineColor: options.drawPathColor || "#ff0000",
                    lineWidth: options.drawPathWidth || 5,
                });
                polyline.addTo(this.map);
                result.lineLayerId = polyline.layerId;
                result.lineSourceId = polyline.sourceId;
            }
            
            let sourceId = result.lineSourceId;
            if (sourceId) {
                // 添加撤销记录
                this.context.ui.addUndoRecord(() => {
                    this.map.removeSourceEx(sourceId);
                });
            }
            return result;
        }
    

    /**
     * 创建天空图层
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.skyType 天空类型,可选值: 'gradient'(渐变) 或 'atmosphere'(模拟大气),默认为'atmosphere'
     * @param {string[]} options.skyGradient 渐变色数组,当skyType为'gradient'时有效
     * @param {[number, number]} options.skyGradientCenter 渐变中心点坐标[经度, 纬度]
     * @param {number} options.skyGradientRadius 渐变半径,梯度延伸的角距离(度),范围0-180,默认90
     * @param {number} options.skyOpacity 天空透明度,范围0-1,默认1
     * @param {string} options.skyAtmosphereColor 大气颜色,用于调整主要大气散射系数,默认白色
     * @param {string} options.skyAtmosphereHaloColor 大气光晕颜色,应用于大气太阳光晕,默认白色
     * @param {number} options.skyAtmosphereSunIntensity 大气太阳光强度,范围0-100,默认10
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 创建天空图层
      * let layer = await this.createSkyLayer();
      * console.log(layer);
     */
    async createSkyLayer(options)  {
            options = options || {};
            let type = "sky";
    
            let randomId = vjmap.RandomID();
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                skyType: 'gradient',
                skyGradient: [
                    'interpolate',
                    ['linear'],
                    ['sky-radial-progress'],
                    0.8,
                    'rgba(135, 206, 235, 1.0)',
                    1,
                    'rgba(0,0,0,0.1)'
                ],
                skyGradientCenter: [0, 0],
                skyGradientRadius: 90,
                skyOpacity: [
                    'interpolate',
                    ['exponential', 0.1],
                    ['zoom'],
                    0,
                    0.3,
                    22,
                    1
                ],
                ...options,
                type: type
            }
           
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId: undefined, layerName, data: undefined, options, layer, visible: true, create: this.createSkyLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId: undefined,
                layerId,
                layerName
            };
        }
    

    /**
     * 弹出列表选择框
     * @param {Array<string>} values 可选值列表内容,必填
     * @param {Object} options 可选值列表配置,可选
     * @param {string|string[]} options.initValue 初始值,可选,默认空
     * @param {boolean} options.isMultiSelect 是否多选,可选,默认false
     * @param {string} options.title 对话框标题,可选
     * @param {Function} options.applyCallback 点击应用按钮的回调函数,可选
     * @returns {string|string[]|undefined} 返回用户选择的值, 如果用户点击取消,则返回undefined
     * @example
      * // 示例一
      * // 弹出列表选择框,列表内容为["a","b","c"]
      * let res = await this.selectOptionsValue(["a","b","c"]);
      * if (res) {
      * // 如果单选,则返回字符串
      * console.log("选择的字符串值为:", res)
      * } else {
      * console.log("点击了取消")
      * }
      * // 示例二
      * // 弹出列表选择框,列表内容为["a","b","c","d"],多选, 标题为"选择", 初始值为["a","b"]
      * let arr = await this.selectOptionsValue(["a","b","c","d"], {
      * isMultiSelect: true,
      * title: "选择",
      * initValue: ["a","b"]
      * });
      * if (arr) {
      * // 如果多选,则返回数组
      * console.log("选择的数组值为:", arr)
      * } else {
      * console.log("点击了取消")
      * }
     */
    selectOptionsValue(values, options)  {
            options = options || {};
            return this.context.ui.selectOptionsValue(values, {
                isMultiSelect: options.isMultiSelect || false,
                initValue: options.initValue || [],
                title: options.title || "选择",
                applyCallback: options.applyCallback || undefined
            });   
         }
    

    /**
     * 移除地图全屏控件
     * @example
      * // 移除地图全屏控件
      * this.removeMapFullscreenControl();
     */
    removeMapFullscreenControl()  {
            this.context.global.controls = this.context.global.controls || {};
            let options;
            if (this.context.global.controls.fullscreenControl) {
                options = {...this.context.global.controls.fullscreenControl.options}
                this.map.removeControl(this.context.global.controls.fullscreenControl.control);
                delete this.context.global.controls.fullscreenControl;
            }
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                if (options) {
                    this.addMapFullscreenControl(options);
                }
            }); 
        }
    
    

    /**
     * 获取所有地图数据或通过指定mapid获取地图数据
     * @param {string} mapid 地图ID. 可选,为空时则获取所有地图数据
     * @param {string} version 版本号. 可选,为空时则获取最新版本, *表示所有版本
     * @returns {Promise<Array<Object>>} 返回地图元数据, 如果失败则返回undefined, 数据每项的字段如下:
     * @example
      * // 示例一
      * // 获取所有地图数据
      * let res = await this.listMaps();
      * console.log(res);
      * // 示例二
      * // 获取地图sys_hello的所有版本数据
      * let res2 = await this.listMaps("sys_hello", "*");
      * console.log(res2);
     */
    async listMaps(mapid, version)  {
            let svc = this.map.getService();
            let res =  await svc.listMaps(mapid, version);
            let result = [];
            if (mapid) {
                if (res && typeof res["version"] === "string") {
                    result.push({
                        mapid: mapid,
                        ...res 
                    });
                    return result;
                }
            } 
            for(let id in res) {
                let data = res[id];
                result.push({
                    mapid: id,
                    ...data
                });
            }
            return result;
         }
    

    /**
     * 获取CAD图层列表信息
     * @param {string} mapid 地图id 可选,为空时则获取当前打开的地图
     * @param {string} version 版本 可选,为空时则获取当前打开的地图版本
     * @returns {Promise<Object[]>} 返回CAD图层列表信息, 每项的属性如下
     * @example
      * // 示例一
      * // 获取CAD图层列表信息
      * let res = await this.getCadLayers();
      * if (res) {
      * this.chatLog("图层名称为:" + res.map(layer => layer.name).join(","));
      * }
      * // 示例二
      * // 获取CAD图sys_world的v1版本图层列表信息
      * let resp = await this.getCadLayers("sys_world", "v1");
      * if (resp) {
      * console.log(resp);
      * }
     */
    async getCadLayers(mapid, version)  {
            let svc = this.map.getService();
            if (!mapid) {
                return svc.getMapLayers();
            } else {
                // 先获取元数据
                let meta = await svc.metadata(mapid, version);
                if (meta && meta.layers) {
                    return meta.layers;
                }
            }
        }
    

    /**
     * 创建点符号数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.iconImage 图标名称,用于绘制图像背景的图像名称
     * @param {number} options.iconRotate 图标旋转角度,顺时针旋转,单位为角度,默认0
     * @param {[number,number]} options.iconOffset 图标与锚点偏移距离,[x,y]格式,正值向右和向下
     * @param {string} options.iconAnchor 图标锚定位置,可选值: "center", "left", "right", "top", "bottom", "top-left", "top-right", "bottom-left", "bottom-right"
     * @param {string} options.iconRotationAlignment 图标旋转对齐方式,可选值: "map", "viewport", "auto"
     * @param {string} options.iconPitchAlignment 地图倾斜时图标方向,可选值: "map", "viewport", "auto"
     * @param {boolean} options.iconAllowOverlap 是否允许图标重叠,默认false
     * @param {number} options.iconOpacity 图标透明度,0-1之间,默认1
     * @param {boolean} options.iconIgnorePlacement 是否忽略碰撞检测,默认false
     * @param {boolean} options.iconOptional 图标重叠选项,默认false
     * @param {number} options.iconSize 图标缩放比例,默认1
     * @param {string} options.iconTextFit 图标适应文本方式,可选值: "none", "width", "height", "both"
     * @param {[number,number,number,number]} options.iconTextFitPadding 图标文本匹配padding,[top, right, bottom, left]格式
     * @param {number} options.iconPadding 图标边界填充大小,默认1像素
     * @param {boolean} options.iconKeepUpright 是否防止图标倒置,默认false
     * @param {string} options.iconColor SDF图标颜色,默认"#000000"
     * @param {string} options.iconHaloColor SDF图标光晕颜色,默认"rgba(0, 0, 0, 0)"
     * @param {number} options.iconHaloWidth 图标光晕宽度,默认0
     * @param {number} options.iconHaloBlur 图标光晕模糊度,默认0
     * @param {[number,number]} options.iconTranslate 图标平移距离,[x,y]格式
     * @param {string} options.iconTranslateAnchor 图标平移参考系,可选值: "map", "viewport"
     * @param {string} options.textField 文本内容
     * @param {string[]} options.textFont 文本字体,默认["Open Sans Regular","Arial Unicode MS Regular"]
     * @param {number} options.textSize 文本大小,默认16
     * @param {boolean} options.textAllowOverlap 是否允许文本重叠,默认false
     * @param {string} options.textColor 文本颜色,默认"#000000"
     * @param {number} options.textOpacity 文本透明度,0-1之间,默认1
     * @param {[number,number]} options.textOffset 文本偏移,[x,y]格式
     * @param {number} options.textRotate 文本旋转角度
     * @param {number} options.textPadding 文本内边距,默认2
     * @param {boolean} options.textKeepUpright 是否防止文本倒置,默认true
     * @param {number} options.textMaxWidth 文本最大宽度,默认10em
     * @param {number} options.textLineHeight 文本行高,默认1.2
     * @param {number} options.textLetterSpacing 文字间距,默认0
     * @param {string} options.textJustify 文本对齐方式,可选值: "auto", "left", "center", "right"
     * @param {string} options.textAnchor 文本锚点位置
     * @param {string} options.textRotationAlignment 文本旋转对齐方式
     * @param {string} options.textPitchAlignment 文本倾斜对齐方式
     * @param {number} options.textMaxAngle 相邻字符最大角度,默认45°
     * @param {string[]} options.textWritingMode 文本书写模式
     * @param {string} options.textTransform 文本转换方式,可选值: "none", "uppercase", "lowercase"
     * @param {number} options.textRadialOffset 文本径向偏移
     * @param {string[]} options.textVariableAnchor 文本可变锚点位置数组
     * @param {boolean} options.textIgnorePlacement 是否忽略文本位置
     * @param {boolean} options.textOptional 文本显示选项
     * @param {string} options.textHaloColor 文本光晕颜色
     * @param {number} options.textHaloWidth 文本光晕宽度
     * @param {number} options.textHaloBlur 文本光晕模糊度
     * @param {[number,number]} options.textTranslate 文本平移距离
     * @param {string} options.textTranslateAnchor 文本平移参考系
     * @param {string} options.symbolPlacement 符号放置位置,可选值: "point", "line", "line-center"
     * @param {number} options.symbolSpacing 符号间距,默认250
     * @param {boolean} options.symbolAvoidEdges 是否避免边缘碰撞
     * @param {string} options.symbolZOrder 符号绘制顺序,可选值: "auto", "viewport-y", "source"
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer24的点符号数据图层, 图标名称为_markerIcon_
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createSymbolDataLayer(geojson, {
      * layerName: 'layer24',
      * iconImage: '_markerIcon_'
      * });
      * console.log(layer);
     */
    async createSymbolDataLayer(data, options)  {
            options = options || {};
            let type = "symbol";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
    
            if (options.textField && data.features.length > 0 && data.features[0].properties && (options.textField in data.features[0].properties)) {
                // 如果内容是geojson中的一个属性,则需要获取该属性值
                options.textField = "['get', '" + options.textField + "']";
            }
            let layerOptions = {
                layerId,
                sourceId,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createSymbolDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建点符号聚合数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.iconImage 图标名称,用于绘制图像背景的图像名称
     * @param {number} options.iconRotate 图标旋转角度,顺时针旋转,单位为角度,默认0
     * @param {[number,number]} options.iconOffset 图标与锚点偏移距离,[x,y]格式,正值向右和向下
     * @param {string} options.iconAnchor 图标锚定位置,可选值: "center", "left", "right", "top", "bottom", "top-left", "top-right", "bottom-left", "bottom-right"
     * @param {string} options.iconRotationAlignment 图标旋转对齐方式,可选值: "map", "viewport", "auto"
     * @param {string} options.iconPitchAlignment 地图倾斜时图标方向,可选值: "map", "viewport", "auto"
     * @param {boolean} options.iconAllowOverlap 是否允许图标重叠,默认false
     * @param {number} options.iconOpacity 图标透明度,0-1之间,默认1
     * @param {boolean} options.iconIgnorePlacement 是否忽略碰撞检测,默认false
     * @param {boolean} options.iconOptional 图标重叠选项,默认false
     * @param {number} options.iconSize 图标缩放比例,默认1
     * @param {string} options.iconTextFit 图标适应文本方式,可选值: "none", "width", "height", "both"
     * @param {[number,number,number,number]} options.iconTextFitPadding 图标文本匹配padding,[top, right, bottom, left]格式
     * @param {number} options.iconPadding 图标边界填充大小,默认1像素
     * @param {boolean} options.iconKeepUpright 是否防止图标倒置,默认false
     * @param {string} options.iconColor SDF图标颜色,默认"#000000"
     * @param {string} options.iconHaloColor SDF图标光晕颜色,默认"rgba(0, 0, 0, 0)"
     * @param {number} options.iconHaloWidth 图标光晕宽度,默认0
     * @param {number} options.iconHaloBlur 图标光晕模糊度,默认0
     * @param {[number,number]} options.iconTranslate 图标平移距离,[x,y]格式
     * @param {string} options.iconTranslateAnchor 图标平移参考系,可选值: "map", "viewport"
     * @param {string|Expression} options.textField 文本标签内容
     * @param {string[]} options.textFont 文本字体,默认["Open Sans Regular","Arial Unicode MS Regular"]
     * @param {number} options.textSize 文本大小,默认16
     * @param {boolean} options.textAllowOverlap 是否允许文本重叠,默认false
     * @param {string} options.textColor 文本颜色,默认"#000000"
     * @param {number} options.textOpacity 文本透明度,0-1之间,默认1
     * @param {[number,number]} options.textOffset 文本偏移,[x,y]格式
     * @param {number} options.textRotate 文本旋转角度
     * @param {number} options.textPadding 文本内边距,默认2
     * @param {boolean} options.textKeepUpright 是否防止文本倒置,默认true
     * @param {number} options.textMaxWidth 文本最大宽度,默认10em
     * @param {number} options.textLineHeight 文本行高,默认1.2
     * @param {number} options.textLetterSpacing 文字间距,默认0
     * @param {string} options.textJustify 文本对齐方式,可选值: "auto", "left", "center", "right"
     * @param {string} options.textAnchor 文本锚点位置
     * @param {string} options.textRotationAlignment 文本旋转对齐方式
     * @param {string} options.textPitchAlignment 文本倾斜对齐方式
     * @param {number} options.textMaxAngle 相邻字符最大角度,默认45°
     * @param {string[]} options.textWritingMode 文本书写模式
     * @param {string} options.textTransform 文本转换方式,可选值: "none", "uppercase", "lowercase"
     * @param {number} options.textRadialOffset 文本径向偏移
     * @param {string[]} options.textVariableAnchor 文本可变锚点位置数组
     * @param {boolean} options.textIgnorePlacement 是否忽略文本位置
     * @param {boolean} options.textOptional 文本显示选项
     * @param {string} options.textHaloColor 文本光晕颜色
     * @param {number} options.textHaloWidth 文本光晕宽度
     * @param {number} options.textHaloBlur 文本光晕模糊度
     * @param {[number,number]} options.textTranslate 文本平移距离
     * @param {string} options.textTranslateAnchor 文本平移参考系
     * @param {string} options.symbolPlacement 符号放置位置,可选值: "point", "line", "line-center"
     * @param {number} options.symbolSpacing 符号间距,默认250
     * @param {boolean} options.symbolAvoidEdges 是否避免边缘碰撞
     * @param {string} options.symbolZOrder 符号绘制顺序,可选值: "auto", "viewport-y", "source"
     * @param {number} options.clusterMaxZoom 聚合最大缩放级别,超过此级别不再聚合,默认10
     * @param {number} options.clusterRadius 聚合的半径范围,单位像素,默认60
     * @param {Array<[number, string]>} options.outerColors 聚合外部圆的值和颜色分级设置,格式为[[值, 颜色], ...],默认[[1000, 'rgba(253, 156, 115, 0.6)'], [100, 'rgba(241, 211, 87, 0.6)'], [0, 'rgba(181, 226, 140, 0.6)']]
     * @param {number} options.outerCircleRadius 聚合外部圆的半径,单位像素,默认20
     * @param {Array<[number, string]>} options.innerColors 聚合内部圆的值和颜色分级设置,格式为[[值, 颜色], ...],默认[[1000, 'rgba(241, 128, 23, 0.6)'], [100, 'rgba(240, 194, 12, 0.6)'], [0, 'rgba(110, 204, 57, 0.6)']]
     * @param {number} options.innerCircleRadius 聚合内部圆的半径,单位像素,默认15
     * @param {number} options.clusterTextSize 聚合文本的字体大小,单位像素,默认12
     * @param {string} options.color 标记颜色,参数可选,默认为'#3FB1CE'
     * @param {number[]} options.offset 偏离XY像素值,如[0,0],负数表示向左和向上
     * @param {number} options.rotation 标记旋转角度,顺时针旋转,默认0
     * @param {string} options.anchor 标记锚点位置,可选值:center、top、bottom、left、right、top-left、top-right、bottom-left、bottom-right,默认center
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型:MAP_ANIMATION_NONE(无动画)、MAP_ANIMATION_BOUNCE(弹跳)、MAP_ANIMATION_DROP(坠落)
     * @param {string} options.rotationAlignment 旋转对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {string} options.pitchAlignment 倾斜对齐:auto(自动)、map(相对地图)、viewport(相对视口),默认auto
     * @param {number} options.scale 缩放比例,默认1,对应高度41px宽度27px
     * @param {number} options.scaleMaxZoom 能缩放的最大级别(0-24),小于此级别时自动缩放
     * @param {number} options.height 标高值,单位CAD图制图单位
     * @param {boolean} options.removeWhenNoInMapView 是否在视图范围内自动显隐
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐的padding像素值,默认500
     * @param {number} options.clickTolerance 点击像素容差,默认继承地图的clickTolerance
     * @param {string} options.customImage 自定义图片地址/base64/svg内容
     * @param {number} options.customImageWidth 自定义图片宽度
     * @param {number} options.customImageHeight 自定义图片高度
     * @param {string} options.customHtml 自定义Html元素的JS代码
     * @param {string} options.popupHtml 信息窗口HTML内容
     * @param {[number,number]} options.popupOffset 信息窗口偏离XY像素值
     * @param {string} options.popupAnchor 信息窗口锚点位置,同anchor参数
     * @param {boolean} options.closeButton 是否显示关闭按钮
     * @param {boolean} options.closeOnClick 是否在点击地图时关闭弹出窗口
     * @param {boolean} options.closeOnMove 是否在地图移动后关闭信息窗口
     * @param {boolean} options.focusAfterOpen 是否尝试聚焦弹出窗口内第一个可聚焦元素
     * @param {string} options.className 添加到弹出容器的CSS类名
     * @param {string} options.maxWidth 弹出窗口最大宽度,CSS属性字符串,默认'240px'
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer25的点符号聚合数据图层, 图标名称为_markerIcon_
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createSymbolClusterDataLayer(geojson, {
      * layerName: 'layer25',
      * iconImage: '_markerIcon_'
      * });
      * console.log(layer);
     */
    async createSymbolClusterDataLayer(data, options)  {
            options = options || {};
            let type = "symbolCluster";
        
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                clusterMaxZoom: 10,
                clusterRadius: 60,
                outerColors: [[1000, 'rgba(253, 156, 115, 0.6)'], [100, 'rgba(241, 211, 87, 0.6)'], [0, 'rgba(181, 226, 140, 0.6)']],
                outerCircleRadius: 20,
                innerColors: [[1000, 'rgba(241, 128, 23, 0.6)'], [100, 'rgba(240, 194, 12, 0.6)'], [0, 'rgba(110, 204, 57, 0.6)']],
                innerCircleRadius: 15,
                clusterTextSize: 12,
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createSymbolClusterDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 测量角度
     * @example
      * // 测量角度
      * await this.measureAngle();
     */
    measureAngle()  {
                vjcommon.runMeasureCmd(this.map, "measureAngle");
            }
    
    

    /**
     * 获取所有数据图层
     * @returns {Array<Object>} 所有数据图层, 返回的数据图层对象包含
     * @example
      * // 获取所有数据图层的图层名称
      * let layers = this.getAllDataLayers();
      * let layerNames = layers.map(layer => layer.layerName);
      * console.log("所有数据图层名称:", layerNames);
     */
    getAllDataLayers()  {
            let layers = this.context.global.layers;
            if(layers) {
                
                return layers.map(item => {
                    let layerId = item.layerId;
                    let sourceId = item.sourceId;
                    if (item.layer && typeof(item.layer.getLayerId) == "function") {
                        layerId = item.layer.getLayerId();
                        let style = this.map.getStyle();
                        let layer = style.layers.find(layer => layer.id == layerId);
                        if (layer && layer.source) {
                            sourceId = layer.source;
                        }
                    }
                    return {
                        layerId: layerId,
                        sourceId: sourceId,
                        visible: item.visible,
                        type: item.type,
                        layer: item.layer,
                        name: item.name
                    }
                });
            } else {
                return [];
            }
        }
    
    

    /**
     * 对地图重命名
     * @param {string} oldMapID 旧地图ID
     * @param {string} newMapID 新地图ID
     * @returns {Promise<boolean>} 返回重命名结果true表示成功,false表示失败
     * @example
      * // 将地图ID从old_hello重命名为new_hello
      * let ok = await this.renameMap("old_hello", "new_hello");
      * console.log(ok);
     */
    async renameMap(oldMapID, newMapID)  {
           let svc = this.map.getService();
           let res = await svc.cmdRenameMap(oldMapID, newMapID);
           return res && res.status;
       }
    

    /**
     * 创建调试瓦片图层
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {number} options.rasterOpacity 图片的不透明度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterHueRotate 在色轮上旋转色相的角度,参数可选,默认值为 0,单位:角度
     * @param {number} options.rasterBrightnessMin 图片的最小亮度,参数可选,取值范围为 0 ~ 1,默认值为 0
     * @param {number} options.rasterBrightnessMax 图片的最大亮度,参数可选,取值范围为 0 ~ 1,默认值为 1
     * @param {number} options.rasterSaturation 图片的饱和度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {number} options.rasterContrast 图片的对比度,参数可选,取值范围为 -1 ~ 1,默认值为 0
     * @param {number} options.rasterFadeDuration 切换瓦片时的渐隐时间,参数可选,默认值为 300,单位:毫秒
     * @param {string} options.rasterResampling 采样方式,参数可选,可选值为 linear、nearest,默认值为 linear
     * @param {string} options.color 颜色, 格式为#RRGGBB
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 创建调试瓦片图层
      * let layer = await this.createDebugLayer();
      * console.log(layer);
     */
    async createDebugLayer(options)  {
            options = options || {};
            let type = "raster";
    
            let randomId = vjmap.RandomID();
            let sourceId = `source_${type}_${randomId}`;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                sourceId,
                layerId,
                ...options,
                type: type
            }
    
            let isVector = this.map.hasVectorLayer() ? "&vector=true" : ''
            let r = 255, g = 255, b = 0, a = 255;
           
            if (options.color && options.color.startsWith('#') && options.color.length === 7) {
                r = parseInt(options.color.slice(1, 3), 16);
                g = parseInt(options.color.slice(3, 5), 16);
                b = parseInt(options.color.slice(5, 7), 16);
            }
            let svc = this.map.getService();
            let tiles = svc.serviceUrl('this.map/') + `tile/debug/{z}/{x}/{y}?r=${r}&g=${g}&b=${b}&a=${a}${isVector}&token=${svc.accessToken}`;
            let sourceData = {
                type: "raster",
                tiles: [tiles],
                tileSize: this.map.hasVectorLayer() ? 512 : 256
            }
           
            this.map.addRasterSource(sourceId, sourceData);
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data: sourceData, options, layer, visible: true, create: this.createDebugLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建Geojson点面线图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.fillColor 填充颜色
     * @param {string} options.fillOutlineColor 边框颜色
     * @param {number} options.fillOpacity 填充透明度,取值范围0-1
     * @param {string} options.fillPattern 填充图案,必须与地图已加载的图片名称对应,图像宽度必须是2的系数(2、4、8、...、512)
     * @param {[number,number]} options.fillTranslate 几何体的平移量[x,y],负数分别表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillTranslateAnchor 平移参考系,"map"表示相对于地图平移,"viewport"表示相对于视窗平移
     * @param {boolean} options.fillAntialias 是否启用填充反锯齿
     * @param {string} options.lineColor 线条颜色,参数可选,默认为'#ff0000'
     * @param {number} options.lineWidth 线宽,参数可选,默认为1
     * @param {number} options.lineOpacity 线透明度,参数可选,取值范围0-1
     * @param {number} options.lineGapWidth 线间隙宽度,参数可选,默认为1,单位像素
     * @param {number} options.lineOffset 线的偏移量,参数可选。正值向右/内偏移,负值向左/外偏移
     * @param {number} options.lineBlur 线模糊度,参数可选,需小于线宽度
     * @param {[number,number]} options.lineDasharray 虚线样式,参数可选,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,参数可选,格式如[x,y],负数表示左和上,单位像素
     * @param {string} options.lineCap 线帽形状,参数可选,可选值:'butt'(尖头)、'round'(圆头)、'square'(平头)
     * @param {string} options.lineJoin 拐角形状,参数可选,可选值:'bevel'(平拐)、'round'(圆拐)、'miter'(棱拐)
     * @param {string} options.linePattern 线图案,参数可选,需与预加载的图片名称对应,图像宽度必须是2的幂次
     * @param {string} options.lineGradient 线渐变,参数可选
     * @param {number} options.circleRadius 圆半径,单位像素,参数可选
     * @param {string} options.circleColor 圆填充颜色,支持十六进制颜色值,参数可选
     * @param {number} options.circleOpacity 圆填充透明度,取值范围0-1,参数可选
     * @param {string} options.circleStrokeColor 圆边框颜色,支持十六进制颜色值,参数可选
     * @param {number} options.circleStrokeWidth 圆边框宽度,单位像素,参数可选
     * @param {number} options.circleStrokeOpacity 圆边框透明度,取值范围0-1,参数可选
     * @param {number} options.circleBlur 圆模糊度,参数可选
     * @param {[number,number]} options.circleTranslate 平移量,格式[x,y],负数表示向左和向上平移,单位像素,默认[0,0],参数可选
     * @param {string} options.circleTranslateAnchor 平移参考系,'map'表示相对地图平移,'viewport'表示相对视窗平移,参数可选
     * @param {string} options.circlePitchScale 倾斜时缩放对齐方式,'map'相对地图,'viewport'相对视窗,参数可选
     * @param {string} options.circlePitchAlignment 倾斜时对齐方式,'map'相对地图,'viewport'相对视窗,参数可选
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer29的Geojson点面线图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createGeojsonDataLayer(geojson, {
      * layerName: 'layer29',
      * });
      * console.log(layer);
     */
    async createGeojsonDataLayer(data, options)  {
            options = options || {};
            let type = "geojson";
      
            if  (options.entColorToHtmlColor === undefined) {
              for(let f of data.features) {
                if (f.properties && typeof f.properties.color == "number") {
                    if (f.properties.color < 0) {
                        options.entColorToHtmlColor = true;
                        break;
                      }
                  }
              }
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillColor: "#00ffff",
                fillOutlineColor: "#00ff00",
                lineColor: '#ff0000',
                lineWidth: 1,
                circleRadius: 5,
                circleColor: "#ffff00",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createGeojsonDataLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建div覆盖物图层
     * @param {[number,number,number,number] | [[number,number],[number,number]] | [[number,number],[number,number],[number,number],[number,number]]} data 范围坐标,格式为左上角和右下角坐标[x1,y1,x2,y2] 或 [[x1,y1],[x2,y2]],或四个角坐标[[x1,y1],[x2,y2],[x3,y3],[x4,y4]]
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {number} options.width div元素的像素宽度
     * @param {number} options.height div元素的像素高度
     * @param {string} options.customImage 图片名称
     * @param {string} options.customHtml 自定义Html元素的JavaScript代码,返回创建的DOM元素
     * @param {number} options.minZoom 图层显示的最小缩放级别,范围0-24
     * @param {number} options.maxZoom 图层显示的最大缩放级别,范围0-24
     * @param {number} options.maxPitch 图层显示的最大倾斜角度,范围0-90
     * @param {boolean} options.updateDivSize 是否自动更新div大小,对SVG放大特别有用
     * @param {number} options.maxDivSize div元素允许的最大像素尺寸,超过此值将使用像素放大
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 采集一个矩形坐标,根据此矩形范围坐标,创建图层名称为layer30的div覆盖物图层,图片名称为picture1
      * const rect = await this.actionDrawRectangle();
      * if (!rect) return;
      * let layer = await this.createDivOverlayLayer(rect,{
      * layerName: 'layer30',
      * customImage: 'picture1'
      * });
      * console.log(layer);
     */
    async createDivOverlayLayer(data, options)  {
            options = options || {};
            let type = "divOverlay";
    
            let randomId = vjmap.RandomID();
            let layerId =  `layer_${type}_${randomId}`;
    
            options.bounds = data;
            if (options.customImage) {
                let image = this.context.ui.getCustomImages(options.customImage);
                if (image) {
                    options.customImage = image.value;
                    options.width = image.width;
                    options.height = image.height;
                }
            }
            if (Array.isArray(options.bounds) && options.bounds.length == 4 && typeof options.bounds[0] == 'number') {
                options.bounds = vjmap.GeoBounds.fromArray(options.bounds).toPointArray();
            }
            let layerOptions = {
                layerId,
                ...options,
                type: type
            }
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId: undefined, layerName, data: undefined, options, layer, visible: true, create: this.createDivOverlayLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId: undefined,
                layerId,
                layerName
            };
        }
    

    /**
     * 查询全部块实体
     * @param {string | string[]} blockName 要查询的块名称或块名称数组,参数可选,默认为空,为空时查询全部块
     * @returns {Object} 返回标准的GeoJson格式的FeatureCollection对象, 包含features属性, 每个feature包含geometry和properties属性,properties属性中包含如下字段:
     * @example
      * // 查询全部块实体
      * let geoJson = await this.queryMapAllBlock();
      * // 获取结果
      * console.log(geoJson)
     */
    async queryMapAllBlock(blockName)  {
            let svc = this.map.getService();
            let query = await svc.exprQueryFeature({
                // 先表达式查询所有的块实体,因为如何用条件查询的话,块已经转为了离散的空间数据,不能整体查了,所以先通过表达式查询出块信息
                /// 以下是查所有块。如果要查询某个具体的块名可以这样写  expr: `gOutReturn := if((gInFeatureType == 'AcDbBlockReference' and gInAttrs4 == '您要查询的块名称'), 1, 0);`,
                expr: `gOutReturn := if((gInFeatureType == 'AcDbBlockReference'), 1, 0);`,
                fields: "objectid,blockname,layername,positon,rotate,scaleX,scaleY,scaleZ,bounds", // 为空的话,表达所有字段
                geom: false, // 内存模式
                useCache: true,
                limit: 1000000 // 数量大些,相当于查找所有的
            })
            let blockNameSet = new Set();
            if (Array.isArray(blockName)) {
                blockName.forEach(name => {
                    blockNameSet.add(name)
                })
            } else if (typeof blockName === "string") {
                blockNameSet.add(blockName)
            }
            let geoJson = {
                type: "FeatureCollection",
                features: []
            }
            if (query.error) {
                this.map.logInfo(query.error, "error")
                return geoJson
            }
            for(let i = 0; i < query.result.length; i++) {
                if (blockNameSet.size > 0 && !blockNameSet.has(query.result[i].blockname)) {
                    continue
                }
                query.result[i].bounds = vjmap.GeoBounds.fromString(query.result[i].bounds).toArray();
                let feature = {
                    type: "Feature",
                    geometry: {
                        type: "Point",
                        coordinates: vjmap.GeoPoint.fromString(query.result[i].positon).toArray()
                    },
                    properties: query.result[i]
                }
                geoJson.features.push(feature)
            }
            return geoJson
        }
    

    /**
     * 测量面积
     * @example
      * // 测量面积
      * await this.measureArea();
     */
    measureArea()  {
                vjcommon.runMeasureCmd(this.map, "measureArea");
            }
    
    

    /**
     * 把geojson数据按给定的四参数进行转换
     * @param {Object} data 要转换的geojson数据,参数必填
     * @param {Object} transform 要转换的四参数,平移{dx: number, dy: number},缩放{scale: number},旋转弧度{rotate: number},参数必填
     * @param {boolean} isLngLatCoord 传入的是否为经纬度坐标,默认false为CAD图几何坐标,true为地图经纬度坐标,参数可选
     * @returns {Object} 返回转换后的geojson数据
     * @example
      * // 把geojson数据按给定的四参数进行转换,平移[100, 200],缩放  0.5,旋转0.5弧度
      * let newGeojson = this.geojsonTransform(geojson, {dx: 100, dy: 200, scale: 0.5, rotate: 0.5});
      * console.log(newGeojson);
     */
    geojsonTransform(data, transform, isLngLatCoord)  {
            return vjmap.transform.convert(data, (pt) => {
                let point = isLngLatCoord === true ? this.map.fromLngLat(vjmap.geoPoint(pt)) : vjmap.geoPoint(pt);
                let newPoint  = vjmap.coordTransfromByFourParamter(point, {
                    dx: transform.dx || 0,
                    dy: transform.dy || 0,
                    scale: transform.scale || 1,
                    rotate: transform.rotate || 0
                });
                return isLngLatCoord === true ? this.map.toLngLat(newPoint) : [newPoint.x, newPoint.y];
            });
        }
    

    /**
     * 创建扩散的点数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {string} options.text 要显示的文字,参数可选,默认为"index ${props.index}"
     * @param {number} options.minZoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxZoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isDrawLinePoint 绘制点时包括线上所有点, 参数可选,默认为false
     * @param {number} options.width 像素宽度,参数可选,默认为24
     * @param {number} options.markerHeight 像素高度,参数可选
     * @param {string} options.color1 颜色值一,参数可选
     * @param {string} options.color2 颜色值二,参数可选
     * @param {number} options.textFontSize 字体大小,参数可选
     * @param {string} options.textColor 字体颜色,参数可选
     * @param {boolean} options.draggable 是否可拖动,参数可选,默认为false
     * @param {string} options.animationType 动画类型,参数可选,无动画 MAP_ANIMATION_NONE,弹跳 MAP_ANIMATION_BOUNCE, 坠落 MAP_ANIMATION_DROP
     * @param {number} options.rotation 旋转角度,参数可选
     * @param {string} options.rotationAlignment 旋转对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {string} options.pitchAlignment 倾斜对齐,参数可选, 自动 auto, 相对于地图 map, 相对于视口 viewport
     * @param {number} options.height 坐标标高值,参数可选
     * @param {number} options.scaleMaxZoom 能缩放的最大级别,参数可选
     * @param {boolean} options.removeWhenNoInMapView 视图范围内自动显隐,参数可选
     * @param {number} options.removeWhenNoInMapViewPadding 视图范围内自动显隐Padding像素范围,参数可选,默认500
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer9的扩散的点数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createDiffusedMarkerLayer(geojson, {
      * layerName: 'layer9'
      * });
      * console.log(layer);
     */
    async createDiffusedMarkerLayer(data, options)  {
            options = options || {};
            let type = "diffusedMarker";
        
    
            if (options.height) {
              options.height = this.map.geoLengthToHeight(options.height);
            }
            
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                text: "ID:${props.index}",
                width: 30,
                markerHeight: 30,
                color1: "#ff0000",
                color2: "#ffff00",
                textFontSize: 15,
                textColor: "#00ffff",
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createDiffusedMarkerLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 创建多边形拉伸数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {string} options.fillExtrusionColor 拉伸颜色,参数可选,默认为"#00ffff"
     * @param {number} options.fillExtrusionOpacity 透明度,参数可选,取值范围0-1
     * @param {number} options.fillExtrusionHeight 拉伸高度,单位CAD图制图单位,参数可选,默认为0
     * @param {number} options.fillExtrusionBase 拉伸底部高度,单位CAD图制图单位,参数可选,默认为0
     * @param {string} options.fillExtrusionPattern 拉伸填充图案,参数可选,使用雪碧图中的图像名称,图像宽度必须是2的系数
     * @param {[number,number]} options.fillExtrusionTranslate 平移量,参数可选,格式[x,y],负数表示左和上,单位像素,默认[0,0]
     * @param {string} options.fillExtrusionTranslateAnchor 平移参考系,参数可选,"map"表示相对地图平移,"viewport"表示相对视窗平移
     * @param {boolean} options.fillExtrusionVerticalGradient 是否应用垂直渐变,参数可选,true时侧面下方位置会略暗
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer12的多边形拉伸数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createFillExtrusionLayer(geojson, {
      * layerName: 'layer12'
      * });
      * console.log(layer);
     */
    async createFillExtrusionLayer(data, options)  {
            options = options || {};
            let type = "fillExtrusion";
        
    
            if(options.fillExtrusionHeight) {
              options.fillExtrusionHeight = this.map.geoLengthToHeight(options.fillExtrusionHeight);
            }
            if(options.fillExtrusionBase) {
              options.fillExtrusionBase = this.map.geoLengthToHeight(options.fillExtrusionBase);
            }
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                fillExtrusionColor: "#00ffff",
                fillExtrusionHeight: this.map.geoLengthToHeight(this.map.getGeoBounds().width() / 6),
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createFillExtrusionLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 移除一个功能菜单
     * @param {string} name 菜单名
     * @example
      * // 移除菜单名为全图显示的功能菜单
      * this.removeMenuItem("全图显示")
     */
    removeMenuItem(name, func)  {
            this.context.ui.removeMenuItem(name, func);   
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.addMenuItem(name, func);
            });
         }
    

    /**
     * 选择图中实体对象
     * @param {object} options 选择实体对象的选项,参数可选
     * @param {boolean} options.useGeomCoord 使用几何坐标还是位置坐标,false表示位置坐标,true表示几何坐标,参数可选, 默认几何坐标true
     * @param {boolean} options.includeWholeEntity 选择时是否选择上整个实体对象,true表示选择上整个实体对象,false表示选择上实体对象的一部分,参数可选, 默认false
     * @param {boolean} options.isPointSel 点选还是框选,false表示框选,true表示点选,参数可选, 默认false
     * @param {boolean} options.disableSnap 是否禁用捕捉,false表示不禁用捕捉,true表示禁用捕捉,参数可选, 默认false
     * @param {number} options.maxSelectCount 最大选择数量,参数可选, 默认不限制
     * @returns {Object} 返回标准的GeoJson格式的FeatureCollection对象, 包含features属性, 每个feature包含geometry和properties属性,properties属性中包含如下字段:
     * @example
      * // 示例一
      * // 点击选择图中实体对象
      * const geojson1 = await this.selectFeatures({
      * isPointSel: true
      * });
      * // 输出选择的实体objectid
      * let selectedObjectids = [];
      * for (let feature of geojson1.features) {
      * selectedObjectids.push(feature.properties.objectid);
      * }
      * console.log(selectedObjectids);
      * // 示例二
      * // 框选图中实体对象, 使用位置坐标, 选择整个实体对象
      * const geojson2 = await this.selectFeatures({
      * useGeomCoord: false,
      * includeWholeEntity: true,
      * isPointSel: false
      * });
      * // 输出选择实体的个数
      * console.log(geojson2.features.length);
      * // 示例三
      * // 点击选择图中的实体对象,选择整个实体对象, 最多选择1个
      * const geojson3 = await this.selectFeatures({
      * isPointSel: true,
      * includeWholeEntity: true,
      * maxSelectCount: 1
      * });
      * console.log(geojson3);
     */
    async selectFeatures(options)  {
            options = options || {};
            let features = await vjcommon.selectFeatures(this.map, options.useGeomCoord !== false, options.includeWholeEntity, options.isPointSel, options.disableSnap, undefined, options.maxSelectCount);
            return {
              features: features || [],
              type: "FeatureCollection"
            }
          }
    

    /**
     * 创建路径动画数据图层
     * @param {GeoJson} data 数据内容,标准的GeoJson格式,参数必填
     * @param {Record<string, any>} options 图层参数选项,参数可选
     * @param {string} options.layerName 图层名称,参数可选,默认为空, 如果为空,则使用随机id作为图层名称
     * @param {number} options.minzoom 显示最小缩放级别,参数可选,默认为0
     * @param {number} options.maxzoom 显示最大缩放级别,参数可选,默认为24
     * @param {boolean} options.isHoverPointer 是否启用鼠标悬浮事件,参数可选
     * @param {boolean} options.isHoverFeatureState 是否启用悬浮实体状态,参数可选
     * @param {string} options.lineColor 线条颜色,默认#FF9900
     * @param {number} options.lineWidth 线宽,默认10
     * @param {number} options.lineOpacity 线透明度,取值0-1
     * @param {number} options.lineGapWidth 线间隙宽度,在线的实际路径之外绘制描边时的内部间隙宽度
     * @param {number} options.lineOffset 线的偏移量,正值向右偏移,负值向左偏移
     * @param {number} options.lineBlur 线模糊度,需小于线宽度
     * @param {string} options.strokeStyle 线型,'solid'实线或'dashed'虚线
     * @param {[number,number]} options.lineDasharray 虚线样式,格式如[1,1]表示实线虚线的组合
     * @param {[number,number]} options.lineTranslate 平移量,格式[x,y],负数分别表示左和上
     * @param {string} options.lineCap 线帽形状,'butt'尖头、'round'圆头、'square'平头
     * @param {string} options.lineJoin 拐角形状,'bevel'平拐、'round'圆拐、'miter'棱拐
     * @param {string} options.strokeImage 线图案,需与预加载的图片名对应
     * @param {string} options.lineGradient 线渐变
     * @param {boolean} options.showBorder 是否显示线边框,默认true
     * @param {string} options.borderColor 边框颜色,默认#f00
     * @param {number} options.borderWidth 边框宽度
     * @param {number} options.borderOpacity 边框透明度,取值0-1
     * @param {number} options.borderGapWidth 边框间隙宽度
     * @param {number} options.borderOffset 边框偏移量
     * @param {number} options.borderBlur 边框模糊度
     * @param {string} options.borderGradient 边框渐变
     * @param {boolean} options.showDir 是否显示箭头,默认true
     * @param {number} options.dirSize 箭头大小
     * @param {number} options.dirSpacing 箭头间距
     * @param {number} options.dirImageWidth 箭头图像宽度
     * @param {number} options.dirImageHeight 箭头图像高度
     * @param {string} options.dirImageColor 箭头图像颜色
     * @param {string} options.dirIconColor 箭头图标颜色
     * @param {string} options.dirLayout 箭头布局
     * @param {string} options.cursor 鼠标光标形状
     * @param {string} options.iconImage 图标名称,用于绘制图像背景的图像名称
     * @param {number} options.iconRotate 图标旋转角度,顺时针旋转,单位为角度,默认0
     * @param {[number,number]} options.iconOffset 图标与锚点偏移距离,[x,y]格式,正值向右和向下
     * @param {string} options.iconAnchor 图标锚定位置,可选值: "center", "left", "right", "top", "bottom", "top-left", "top-right", "bottom-left", "bottom-right"
     * @param {string} options.iconRotationAlignment 图标旋转对齐方式,可选值: "map", "viewport", "auto"
     * @param {string} options.iconPitchAlignment 地图倾斜时图标方向,可选值: "map", "viewport", "auto"
     * @param {boolean} options.iconAllowOverlap 是否允许图标重叠,默认false
     * @param {number} options.iconOpacity 图标透明度,0-1之间,默认1
     * @param {boolean} options.iconIgnorePlacement 是否忽略碰撞检测,默认false
     * @param {boolean} options.iconOptional 图标重叠选项,默认false
     * @param {number} options.iconSize 图标缩放比例,默认1
     * @param {string} options.iconTextFit 图标适应文本方式,可选值: "none", "width", "height", "both"
     * @param {[number,number,number,number]} options.iconTextFitPadding 图标文本匹配padding,[top, right, bottom, left]格式
     * @param {number} options.iconPadding 图标边界填充大小,默认1像素
     * @param {boolean} options.iconKeepUpright 是否防止图标倒置,默认false
     * @param {string} options.iconColor SDF图标颜色,默认"#000000"
     * @param {string} options.iconHaloColor SDF图标光晕颜色,默认"rgba(0, 0, 0, 0)"
     * @param {number} options.iconHaloWidth 图标光晕宽度,默认0
     * @param {number} options.iconHaloBlur 图标光晕模糊度,默认0
     * @param {[number,number]} options.iconTranslate 图标平移距离,[x,y]格式
     * @param {string} options.iconTranslateAnchor 图标平移参考系,可选值: "map", "viewport"
     * @param {string|Expression} options.textField 文本标签内容
     * @param {string[]} options.textFont 文本字体,默认["Open Sans Regular","Arial Unicode MS Regular"]
     * @param {number} options.textSize 文本大小,默认16
     * @param {boolean} options.textAllowOverlap 是否允许文本重叠,默认false
     * @param {string} options.textColor 文本颜色,默认"#000000"
     * @param {number} options.textOpacity 文本透明度,0-1之间,默认1
     * @param {[number,number]} options.textOffset 文本偏移,[x,y]格式
     * @param {number} options.textRotate 文本旋转角度
     * @param {number} options.textPadding 文本内边距,默认2
     * @param {boolean} options.textKeepUpright 是否防止文本倒置,默认true
     * @param {number} options.textMaxWidth 文本最大宽度,默认10em
     * @param {number} options.textLineHeight 文本行高,默认1.2
     * @param {number} options.textLetterSpacing 文字间距,默认0
     * @param {string} options.textJustify 文本对齐方式,可选值: "auto", "left", "center", "right"
     * @param {string} options.textAnchor 文本锚点位置
     * @param {string} options.textRotationAlignment 文本旋转对齐方式
     * @param {string} options.textPitchAlignment 文本倾斜对齐方式
     * @param {number} options.textMaxAngle 相邻字符最大角度,默认45°
     * @param {string[]} options.textWritingMode 文本书写模式
     * @param {string} options.textTransform 文本转换方式,可选值: "none", "uppercase", "lowercase"
     * @param {number} options.textRadialOffset 文本径向偏移
     * @param {string[]} options.textVariableAnchor 文本可变锚点位置数组
     * @param {boolean} options.textIgnorePlacement 是否忽略文本位置
     * @param {boolean} options.textOptional 文本显示选项
     * @param {string} options.textHaloColor 文本光晕颜色
     * @param {number} options.textHaloWidth 文本光晕宽度
     * @param {number} options.textHaloBlur 文本光晕模糊度
     * @param {[number,number]} options.textTranslate 文本平移距离
     * @param {string} options.textTranslateAnchor 文本平移参考系
     * @param {string} options.symbolPlacement 符号放置位置,可选值: "point", "line", "line-center"
     * @param {number} options.symbolSpacing 符号间距,默认250
     * @param {boolean} options.symbolAvoidEdges 是否避免边缘碰撞
     * @param {string} options.symbolZOrder 符号绘制顺序,可选值: "auto", "viewport-y", "source"
     * @param {number} options.fps 动画帧率,每秒运行多少帧,默认10,把线段分成了100段,每一秒跑多少段,取值范围1-100
     * @returns {Object} 返回对象,包含 {sourceId: string, layerId: string, layerName: string}
     * @example
      * // 在地图范围内随机生成GeoJson数据,创建图层名称为layer21的路径动画数据图层
      * let geojson = this.randomGeojsonInMapBounds();
      * let layer = await this.createPathAnimateLayer(geojson, {
      * layerName: 'layer21',
      * iconImage: 'icon1'
      * });
      * console.log(layer);
     */
    async createPathAnimateLayer(data, options)  {
            options = options || {};
            let type = "pathAnimate";
        
    
            let randomId = vjmap.RandomID();
            let sourceId = "source_geojson_" + randomId;
            let layerId =  `layer_${type}_${randomId}`;
            let layerOptions = {
                layerId,
                sourceId,
                lineWidth: 10,
                showDir: true,
                showBorder: true,
                borderColor: "#f00",
                lineColor: '#FF9900',
                ...options,
                type: type
            }
            // 添加数据源
            this.map.addGeoJSONSource(sourceId, this.map.toLngLat(data));
    
            // 添加图层
            let layer = new vjcommon.providerLayers[layerOptions.type];
            await layer.addLayer(this.map, layerOptions);
    
            let layerName = options.layerName || layerId;
    
            this.context.global.layers = this.context.global.layers || [];
            this.context.global.layers.push({layerId, sourceId, layerName, data, options, layer, visible: true, create: this.createPathAnimateLayer});
    
            // 添加撤销记录
            this.context.ui.addUndoRecord(() => {
                this.deleteDataLayer(layerName);
            });
            return {
                sourceId,
                layerId,
                layerName
            };
        }
    

    /**
     * 移除小地图(鹰眼)控件
     * @example
      * // 移除小地图(鹰眼)控件
      * this.removeMiniMapControl();
     */
    removeMiniMapControl()  {
            this.context.global.controls = this.context.global.controls || {};
            let options;
            if (this.context.global.controls.miniMapControl) {
                options = {...this.context.global.controls.miniMapControl.options}
                this.map.removeControl(this.context.global.controls.miniMapControl.control);
                delete this.context.global.controls.miniMapControl;
            }
            // 增加撤销记录
            this.context.ui.addUndoRecord(() => {
                if (options) {
                    this.addMiniMapControl(options);
                }
            }); 
        }
    

    /**
     * 将CAD图几何坐标转换为地图经纬度坐标
     * @returns {[number, number]} 返回包含两个数字的数组[lng,lat],表示地图经纬度坐标
     * @example
      * // 将CAD图几何坐标[1000, 2000]转换为地图经纬度坐标
      * let point = this.geoPointToLngLat([1000, 2000]);
      * let lng = point[0];
      * let lat = point[1];
      * console.log(lng, lat);
     */
    geoPointToLngLat(pt)  {
            let lngLat = this.map.toLngLat(pt);
            let lng = lngLat[0];
            let lat = lngLat[1];
            return [lng, lat];
        }
    


}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195