npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mapgisapi

v1.0.0

Published

mapgisapi

Readme

class MapClass {
  constructor(options) {
    this.options = options;
    this.ClassType = MapClass.ClassType;
    this.mapInstance = new MapClass.Class(options);// 创建地图 Class在index文件赋值
  }
  /**
   * 地图加载完成
   * @returns Promise
   */
  mapLoaded() {
    return this.mapInstance.mapLoaded();
  }
  /**
   * 添加图层
   * @param {*} item 图层信息
   * {
   *  id: "pipeLayer",
   *  url: BASE_SERVER_URL + "/map-GSPIPE/rest/maps/GSPIPE@ORCL_SM003"
   *  layerType: "MapImageLayer",
   *  visible: true
   * }
   */
  addMapLayer(item) {
    return this.mapInstance.addMapLayer(item)
  }
  /**
   * 刷新图层数据
   * @param {*} layer 图层id或图层对象
   */
  refreshMapLayer(layer) {
    this.mapInstance.refreshMapLayer(layer);
  }
  /**
   * 设置图层显示隐藏
   * @param {String|Array} layerId 图层id
   * @param {Boolean} visible 是否显示
   */
  setLayerVisible(layerId, visible) {
    this.mapInstance.setLayerVisible(layerId, visible);
  }
  /**
   * 设置图层透明度
   * @param {String|Object} layerId 图层id或图层对象
   * @param {Boolean} opacity 透明度0-1
   */
  setLayerOpacity(layerId, opacity) {
    this.mapInstance.setLayerOpacity(layerId, opacity);
  }
  /**
   * 设置图层状态(用于超图图控)
   * @param {*} layerStatus 图层状态
   */
  setLayerStatus(layerStatus) {
    if(MapClass.ClassType === "Arcgis") {
      return;
    }
    this.mapInstance.setLayerStatus(layerStatus);
  }
  /**
   * 设置子图层显示隐藏(arcgis动态图层控制)
   * @param {Object} layer 父级图层
   * @param {String|Array} sublayerId 子图层id
   * @param {Boolean} visible 是否显示
   */
  setSublayerVisible(layer, sublayerId, visible) {
    if(MapClass.ClassType === "Supermap") {
      return;
    }
    this.mapInstance.setSublayerVisible(layer, sublayerId, visible);
  }
  /**
   * 开启卷帘功能
   * @param {HTMLElement} dom 超图卷帘需提供拖动卷帘的DOM元素
   */
  startSwipe(dom) {
    this.mapInstance.startSwipe(dom);
  }
  /**
   * 关闭卷帘功能
   */
  closeSwipe() {
    this.mapInstance.closeSwipe();
  }
  /**
   * 绘制图形
   * @param {String} type 绘制类型 ["point","polyline","polygon","circle","rectangle"]
   * @param {Function} callback 返回绘制geometry,graphic
   * @param {Boolean} isAgain 是否连续绘制
   */
  startDraw(type, callback, isAgain = false) {
    let drawType = {
      Arcgis: {point: "point", polyline: "polyline", polygon: "polygon", circle: "circle", rectangle: "rectangle"},
      Supermap: {point: "Point", polyline: "LineString", polygon: "Polygon", circle: "Circle", rectangle: "rectangle"}
    };
    this.mapInstance.startDraw(drawType[MapClass.ClassType][type], callback, isAgain);
  }
  /**
   * 开启编辑图形
   * @param {Object|String} layer|layerId 图形图层对象或id 注:arcgis需要依赖图层编辑
   * @param {Object<Feature>} feature 要素数据
   * @param {Function} callback 返回编辑后的geometry,graphic
   */
  startEdit(layer, feature, callback) {
    this.mapInstance.startEdit(layer, feature, callback);
  }
  /**
   * 关闭编辑图形
   */
  closeEdit() {
    this.mapInstance.closeEdit();
  }
  /**
   * 测量长度
   * @param {Boolean} isAgain 是否连续测量
   */
  measureLegth(isAgain = false) {
    this.mapInstance.measureLegth(isAgain);
  }
  /**
   * 测量面积
   * @param {Boolean} isAgain 是否连续测量
   */
  measureArea(isAgain = false) {
    this.mapInstance.measureArea(isAgain);
  }
  // 关闭绘制工具
  closeDraw() {
    this.mapInstance.closeDraw();
  }
  // 清除绘制数据
  clearDraw() {
    this.mapInstance.clearDraw();
  }
  // 开启地图截屏功能
  mapScreenShot(options) {
    if(MapClass.ClassType === "Supermap") {
      throw new Error("Supermap not support screen shot!");
    }
    return this.mapInstance.mapScreenShot(options);
  }
  // 地图放大
  zoomIn() {
    this.mapInstance.zoomIn();
  }
  // 地图缩小
  zoomOut() {
    this.mapInstance.zoomOut();
  }
  // 获取地图比例尺
  getViewScale() {
    return this.mapInstance.getViewScale();
  }
  // 设置地图比例尺
  setViewScale(scale) {
    this.mapInstance.setViewScale(scale);
  }
  // 获取当前地图的lods
  getViewLods() {
    return this.mapInstance.getViewLods();
  }
  /**
   * 获取当前缩放级别
   * @returns Number
   */
  getCurZoom() {
    return this.mapInstance.getCurZoom();
  }
  /**
   * 获取当前视图范围
   * @returns Object<Extent> 范围图形数据
   */
  getCurViewExtent() {
    return this.mapInstance.getCurViewExtent();
  }
  /**
   * 获取点的坐标值
   * @param {Object<Point>} point 
   * @returns Object {x,y}
   */
  getPointCoords(point) {
    return this.mapInstance.getPointCoords(point);
  }
  /**
   * 获取线的坐标值
   * @param {Object<Polyline>} polyline 
   * @returns Array [[x, y],[x, y]]
   */
  getPolylineCoords(polyline) {
    return this.mapInstance.getPolylineCoords(polyline);
  }
  /**
   * 获取线的坐标值
   * @param {Object<Polygon>} polygon 
   * @returns Array [[[x, y],[x, y]], [[x, y],[x, y]]]
   */
  getPolygonCoords(polygon) {
    return this.mapInstance.getPolygonCoords(polygon);
  }
  /**
   * 获取图形的中心点
   * @param {Object<geometry>} geometry 
   */
  getGeometryCenter(geometry) {
    return this.mapInstance.getGeometryCenter(geometry);
  }
  /**
   * 获取图形的类型
   * @param {Object<geometry>} geometry 
   */
  getGeometryType(geometry) {
    if(MapClass.ClassType === "Supermap") {
      let typeMap = {
        "Point": "point",
        "LineString": "polyline",
        "MultiLineString": "polyline",
        "Polygon": "polygon",
        "MultiPolygon": "polygon",
      }
      let type = this.mapInstance.getGeometryType(geometry);
      return typeMap[type];
    }
    return this.mapInstance.getGeometryType(geometry);
  }
  /**
   * 坐标缩放定位
   * @param {Number} x x坐标值
   * @param {Number} y y坐标值
   * @param {Number} zoom 缩放级别(可选)
   */
  setCenterZoom(x, y, zoom) {
    this.mapInstance.setCenterZoom(x, y, zoom);
  }
  /**
   * 要素定位
   * @param {Object<Geometry>||Array<Geometry>} geometry 单个或多个图形要素
   * @param {Function} callback 定位结束回调 (可选)
   * @param {Number} zoom 定位级别 (可选)
   */
  zoomToGeometry(geometry, callback, zoom) {
    this.mapInstance.zoomToGeometry(geometry, callback, zoom);
  }
  /**
   * 点坐标转屏幕坐标
   * @param {Object<Geometry>} point 点要素
   * @returns {Object} {x: 123, y: 456}
   */
  pointToScreen(point) {
    let screenCoord = this.mapInstance.pointToScreen(point);
    if(MapClass.ClassType === "Supermap") {
      return {
        x: screenCoord[0],
        y: screenCoord[1],
      } 
    }
    if(MapClass.ClassType === "Arcgis") {
      return screenCoord;
    }
  }
  /**
   * 要素数据转geojson
   * @param {Object<Geometry>} geometry 要素数据
   */
  geometryToGeojson(geometry) {
    return this.mapInstance.geometryToGeojson(geometry);
  }
  /**
   * geojson转要素数据
   * @param {String} geojson geojson格式字符串
   */
  geojsonToGeometry(geojson) {
    return this.mapInstance.geojsonToGeometry(geojson);
  }
  /**
   * 要素数据转wkt
   * @param {Object<Geometry>} geometry 要素数据
   */
  geometryToWkt(geometry) {
    return this.mapInstance.geometryToWkt(geometry);
  }
  /**
   * wkt转要素数据
   * @param {String} wkt wkt格式字符串
   */
  wktToGeometry(wkt) {
    return this.mapInstance.wktToGeometry(wkt);
  }
  /**
   * 图形要素转json
   * @param {Object<Feature>} Feature 要素数据
   */
  featureToJson(Feature) {
    return this.mapInstance.featureToJson(Feature);
  }
  /**
   * json转要素数据
   * @param {String} json json格式字符串
   */
  jsonToFeature(json) {
    return this.mapInstance.jsonToFeature(json);
  }
  /**
   * 创建点图形
   * @param {Number} x x坐标值
   * @param {Number} y y坐标值
   * @returns Object<Point> 点图形数据
   */
  createPoint(x, y) {
    return this.mapInstance.createPoint(x, y);
  }
  /**
   * 创建线图形
   * @param {Number} coordinates 坐标值[[x, y], [x, y]]
   * @returns Object<Polyline> 线图形数据
   */
  createPolyline(coordinates) {
    return this.mapInstance.createPolyline(coordinates);
  }
  /**
   * 创建面图形
   * @param {Number} coordinates 坐标值[[[x, y], [x, y]]]
   * @returns Object<Polygon> 面图形数据
   */
  createPolygon(coordinates) {
    return this.mapInstance.createPolygon(coordinates);
  }
  /**
   * 构建缓冲区
   * @param {Object} geometry 空间数据
   * @param {Number} radius 缓冲半径
   * @param {String} units 单位 meters | kilometers
   * @returns Object<Geometry> 缓冲区图形 
   */
  createBuffer(geometry, radius, units = "meters") {
    return this.mapInstance.createBuffer(geometry, radius, units);
  }
  /**
   * 获取圆点样式
   * @param {Object} options 自定义参数
   * options: {
      color: "#ff0000",
      size: 20,
      outLineColor: "#ffff00",
      outLineWidth: 5,
    }
   * 
   * @param {String|Array} color 填充颜色#ff0000 | [r, g, b, a]
   * @param {Number} size 圆点大小,像素数值值大小
   * @returns Object 样式对象
   */
  getPointStyle(color, size) {
    if(arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Object]') {
      return this.mapInstance.getPointStyleOpt(arguments[0]);
    }
    return this.mapInstance.getPointStyle(color, size);
  }
  /**
   * 获取点图标样式
   * @param {Object} options 自定义参数
   * options: {
      url: require('./assets/mapIcon/marker_blue.png'), 
      imageWidth:"53px", 
      setWidth: "32px", 
      setHeight: "40px", 
      xoffset: "0px", 
      yoffset: "16px"
    }
   * 
   * @param {String} url 图标地址
   * @param {String} imageWidth 原图标宽度 如:"1px"
   * @param {String} setWidth 图标宽度
   * @param {String} setHeight 图标高度
   * @param {String} xoffset x偏移 (可选)
   * @param {String} yoffset y偏移 (可选)
   * @returns Object 样式对象
   */ 
  getMarkerStyle(url, imageWidth, setWidth, setHeight, xoffset, yoffset) {
    if(arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Object]') {
      let options = arguments[0];
      if(MapClass.ClassType === "Supermap") {
        options.scale = parseInt(options.setWidth) / parseInt(options.imageWidth);
        if(parseInt(options.xoffset) >= 0) {
          options.xoffset = parseInt(options.xoffset)* 2 / parseInt(options.setWidth);
        }else {
          options.xoffset = -(parseInt(options.xoffset) / parseInt(options.setWidth)) + 0.5001;
        }
        if(parseInt(options.yoffset) >= 0) {
          options.yoffset = parseInt(options.yoffset)* 2 / parseInt(options.setHeight);
        }else {
          options.yoffset = (parseInt(options.yoffset) / parseInt(options.setHeight)) + 0.5001;
        }
        return this.mapInstance.getMarkerStyleOpt(options);
      }
      if(MapClass.ClassType === "Arcgis") {
        return this.mapInstance.getMarkerStyleOpt(options);
      }
    }else {
      if(MapClass.ClassType === "Supermap") {
        let scale = parseInt(setWidth) / parseInt(imageWidth);
        if(parseInt(xoffset) >= 0) {
          xoffset = parseInt(xoffset)* 2 / parseInt(setWidth);
        }else {
          xoffset = -(parseInt(xoffset) / parseInt(setWidth)) + 0.5001;
        }
        if(parseInt(yoffset) >= 0) {
          yoffset = parseInt(yoffset)* 2 / parseInt(setHeight);
        }else {
          yoffset = (parseInt(yoffset) / parseInt(setHeight)) + 0.5001;
        }
        return this.mapInstance.getMarkerStyle(url, scale, xoffset, yoffset);
      }
      if(MapClass.ClassType === "Arcgis") {
        return this.mapInstance.getMarkerStyle(url, setWidth, setHeight, xoffset, yoffset);
      }
    }
  }
  /**
   * 获取标注样式
   * @param {Object} options 自定义参数
   * options: {
      text: "测试字体1", 
      color: "#ff0000", 
      fontSize: 24, 
      outLineColor: "#ffff00",
      outLineWidth: 5,
      backgroundColor: "#00ff00",
      borderLineColor: "#0000ff",
      borderLineSize: 5,
      xoffset: "0px", 
      yoffset: "24px"
    }
   * 
   * @param {String} text 文本内容
   * @param {String|Array} color 填充颜色#ff0000 | [r, g, b, a]
   * @param {Number} fontSize 字体大小
   * @param {String} xoffset x偏移 (可选)
   * @param {String} yoffset y偏移 (可选)
   * @returns Object 样式对象
   */
  getTextStyle(text, color, fontSize, xoffset, yoffset) {
    if(arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Object]') {
      let options = arguments[0];
      if(MapClass.ClassType === "Supermap") {
        options.xoffset = - parseInt(options.xoffset);
        options.yoffset = - parseInt(options.yoffset);
      }
      return this.mapInstance.getTextStyleOpt(options);
    }
    if(MapClass.ClassType === "Supermap") {
      xoffset = - parseInt(xoffset);
      yoffset = - parseInt(yoffset);
    }
    return this.mapInstance.getTextStyle(text, color, fontSize, xoffset, yoffset);
  }
  /**
   * 获取线样式
   * @param {Object} options 自定义参数
   * options: {
      color: "#ff0000",
      width: 10,
      style: "dash"
    }
   * 
   * @param {String|Array} color 填充颜色#ff0000 | [r, g, b, a]
   * @param {Number} width 线宽度 1
   * @param {String} style 线样式 solid-实线 dash-虚线 (可选)
   * @returns Object 样式对象
   */
  getLineStyle(color, width, style) {
    if(arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Object]') {
      return this.mapInstance.getLineStyleOpt(arguments[0]);
    }
    return this.mapInstance.getLineStyle(color, width, style);
  }
  /**
   * 获取面样式
   * @param {Object} options 自定义参数
   * options: {
      color: [255, 0, 0, 0.3], 
      outLineColor: "#ffff00", 
      outLineWidth: 2,
      outlineStyle: "dash"
    }
   * 
   * @param {String|Array} color 填充颜色#ff0000 | [r, g, b, a]
   * @param {String|Array} outLineColor 边线颜色#ff0000 | [r, g, b, a]
   * @param {Number} outLineWidth 边线宽度 1
   * @param {String} outLineStyle 边线样式 solid-实线 dash-虚线 (可选)
   * @returns Object 样式对象
   */
  getPolygonStyle(color, outLineColor, outLineWidth, outLineStyle) {
    if(arguments.length === 1 && Object.prototype.toString.call(arguments[0]) === '[object Object]') {
      return this.mapInstance.getPolygonStyleOpt(arguments[0]);
    }
    return this.mapInstance.getPolygonStyle(color, outLineColor, outLineWidth, outLineStyle);
  }
  /**
   * 获取默认样式
   * @param {String} type 样式类型'point','marker','line','polygon'
   * @returns Object 样式对象
   */
  getDefaultStyle(type) {
    return this.mapInstance.getDefaultStyle(type);
  }
  /**
   * 设置要素样式
   * @param {Object} feature 图形要素
   * @param {Object} style 样式
   */
  setFeatureStyle(feature, style) {
    this.mapInstance.setFeatureStyle(feature, style);
  }
  /**
   * 设置要素图形信息
   * @param {Object} feature 图形要素
   * @param {Object} geometry 图形信息
   */
  setFeatureGeometry(feature, geometry) {
    this.mapInstance.setFeatureGeometry(feature, geometry);
  }
  /**
   * 设置要素属性信息
   * @param {Object} feature 图形要素
   * @param {Object} attributes 属性信息
   */
  setFeatureAttributes(feature, attributes) {
    this.mapInstance.setFeatureAttributes(feature, attributes);
  }
  /**
   * 创建要素数据
   * @param {Object} geometry 图形对象
   * @param {Object} style 样式
   * @param {Object} attributes 属性(可选)
   * @returns Object<Feature> 要素数据
   */
  createFeature(geometry, style, attributes) {
    return this.mapInstance.createFeature(geometry, style, attributes);
  }
  /**
   * 获取要素的图形对象
   * @param {Object|Array<Feature>} feature 单个/多个要素数据
   * @returns 图形对象数据
   */
  getGeometryByFeature(feature) {
    return this.mapInstance.getGeometryByFeature(feature);
  }
  /**
   * 获取要素的属性对象
   * @param {Object|Array<Feature>} feature 单个/多个要素数据
   * @returns 属性数据
   */
  getAttributeByFeature(feature) {
    return this.mapInstance.getAttributeByFeature(feature);
  }
  /**
   * 添加高亮要素数据
   * @param {Object|Array<Feature>} feature 单个/多个要素数据
   */
  addHighLightFeature(feature) {
    this.mapInstance.addHighLightFeature(feature);
  }
  // 清除高亮图层
  clearHighLightLayer() {
    this.mapInstance.clearHighLightLayer();
  }
  /**
   * 创建图形图层
   * @param {String} id 图层id 
   * @returns 图层对象
   */
  createGraphicsLayer(id) {
    return this.mapInstance.createGraphicsLayer(id);
  }
  /**
   * 删除图层
   * @param {Object|String} layer|layerId 图形图层对象或id
   */
  removeLayer(layer) {
    return this.mapInstance.removeLayer(layer);
  }
  /**
   * 获取图层
   * @param {String} id 图层id 
   * @returns Object 图层对象
   */
  getLayerById(id) {
    return this.mapInstance.getLayerById(id);
  }
  /**
   * 添加要素到图层
   * @param {Object|String} layer|layerId 图形图层对象或id
   * @param {Object|Array<Feature>} feature 单个/多个要素数据
   */
  addFeatureToLayer(layer, feature) {
    this.mapInstance.addFeatureToLayer(layer, feature);
  }
  /**
   * 删除图层某个要素
   * @param {Object|String} layer|layerId 图形图层对象或id
   * @param {Object<Feature>} feature 单个要素数据
   */
  removeFeature(layer, feature) {
    this.mapInstance.removeFeature(layer, feature);
  }
  /**
   * 根据属性删除图层某个要素
   * @param {Object|String} layer|layerId 图形图层对象或id
   * @param {String} field 根据 field字段 删除 
   * @param {String} fieldValue 字段值
   */
  removeFeatureFromLayer(layer, field, fieldValue) {
    this.mapInstance.removeFeatureFromLayer(layer, field, fieldValue);
  }
  /**
   * 清除图形图层
   * @param {Object|String} layer|layerId 图形图层对象或id
   */
  clearGraphicsLayer(layer) {
    this.mapInstance.clearGraphicsLayer(layer);
  }
  /**
   * 创建要素图层
   * @param {Object} item 图层信息
   * {
   *  id: "pipeLayer",
   *  url: BASE_SERVER_URL + "/PRODUCT/GS_pipe_BS/MapServer/0"
   *  visible: true
   * }
   */
  createFeatureLayer(item) {
    if(MapClass.ClassType === "Supermap") {
      throw new Error("Supermap not support FeatureLayer!");
    }
    return this.mapInstance.createFeatureLayer(item);
  }
  // 创建echarts图层
  createEchartsLayer(option) {
    return this.mapInstance.createEchartsLayer(option);
  }
  /**
   * 设置聚合效果
   * @param {Object} layer 需要聚合显示的图层
   * @param {Object} renderer 样式效果
   * @param {Object} redution 聚合效果
   */
  setClusterReduction(layer, renderer, redution) {
    if(MapClass.ClassType === "Supermap") {
      throw new Error("Supermap not support Cluster!");
    }
    this.mapInstance.setClusterReduction(layer, renderer, redution);
  }
  /**
   * 监听地图拖拽事件
   * @param {Function} callback 事件执行回调函数
   * @returns Object 事件对象
   */
  viewDragListener(callback) {
    if(MapClass.ClassType === "Supermap") {
      throw new Error("Supermap not support drag listener!");
    }
    return this.mapInstance.viewDragListener(callback);
  }
  /**
   * 监听地图级别变化
   * @param {Function} callback 事件执行回调函数
   * @returns Object 事件对象
   */
  viewScaleListener(callback) {
    return this.mapInstance.viewScaleListener(callback);
  }
  /**
   * 监听地图范围变化
   * @param {Function} callback 事件执行回调函数
   * @returns Object 事件对象
   */
  viewExtentListener(callback) {
    return this.mapInstance.viewExtentListener(callback);
  }
  /**
   * 监听鼠标移动
   * @param {Function} callback 事件执行回调函数
   * @returns Object 事件对象
   */
  pointerMoveListener(callback) {
    return this.mapInstance.pointerMoveListener(callback);
  }
  /**
   * 地图点击事件
   * @param {Function} callback 返回点击数据{ 坐标:coordinate, 像素坐标:pixel, 当前点位要素:mapPoint }
   * @param {Boolean} isAgain 是否连续点击
   * @returns Object 事件对象
   */
  mapOnClick(callback, isAgain = true) {
    return this.mapInstance.mapOnClick(callback, isAgain);
  }
  /**
   * 地图双击事件
   * @param {Function} callback 返回点击数据{ 坐标:coordinate, 像素坐标:pixel, 当前点位要素:mapPoint }
   * @param {Boolean} isAgain 是否连续点击
   * @returns Object 事件对象
   */
  mapOnDobuleClick(callback, isAgain = true) {
    return this.mapInstance.mapOnDobuleClick(callback, isAgain);
  }
  /**
   * 选中要素数据
   * @param {Function} callback 返回点击要素数据{ 要素数据:feature }
   * @param {Boolean} isAgain 是否连续点击
   * @param {Number} bufferDistance 仅超图支持
   * @returns Object 事件对象
   */
  featureOnSelect(callback, isAgain = true, bufferDistance) {
    return this.mapInstance.featureOnSelect(callback, isAgain, bufferDistance);
  }
  /**
   * 选中所有要素数据
   * @param {Function} callback 返回点击要素数据{ 要素数据:feature[] }
   * @param {Boolean} isAgain 是否连续点击
   * @param {Number} bufferDistance 仅超图支持
   * @returns Object 事件对象
   */
  featureOnSelectAll(callback, isAgain = true, bufferDistance) {
    return this.mapInstance.featureOnSelectAll(callback, isAgain, bufferDistance);
  }
  /**
   * 移除地图事件
   * @param {Object||Array<Object>} event 单个或多个事件对象
   */
  removeMapEvent(event) {
    this.mapInstance.removeMapEvent(event);
  }
  /**
   * 显示弹窗
   * @param {String} title 弹窗标题
   * @param {String|HTMLElement} content 弹窗内容
   * @param {Object<Geometry>} location 弹窗显示位置
   * @param {Function} callback 弹窗关闭后执行回调
   */
  showPopup(title, content, geometry, callback) {
    this.mapInstance.showPopup(title, content, geometry, callback);
  }
  // 关闭弹窗
  closePopup() {
    this.mapInstance.closePopup();
  }
  /**
   * 计算线的长度
   * @param {Object<Geometry>} geometry 图形
   * @returns {Number} 距离
   */
  calcLineLength(geometry) {
    return this.mapInstance.calcLineLength(geometry);
  }
  /**
   * 获取所有图形的凸包面
   * @param {Array<Geometry>} geometries 图形
   * @returns {Polygon} 图形
   */
  getConvexHull(geometries) {
    return this.mapInstance.getConvexHull(geometries);
  }
  /**
   * 获取图形之间的距离
   * @param {Object<Geometry>} geometry1 图形
   * @param {Object<Geometry>} geometry2 图形
   * @returns {Number} 距离
   */
  getGeometryDistance(geometry1, geometry2) {
    return this.mapInstance.getGeometryDistance(geometry1, geometry2);
  }
  /**
   * 合并图形
   * @param {Array<Geometry>} geometries 图形集合
   * @returns {Object<Geometry>} 合并后的图形
   */
  getUnionGeometry(geometries) {
    return this.mapInstance.getUnionGeometry(geometries);
  }
  /**
   * 相交图形
   * @param {Object<Geometry>} geometry1 图形
   * @param {Object<Geometry>} geometry2 图形
   * @returns {Object<Geometry>} 相交图形
   */
  getIntersectGeometry(geometry1, geometry2) {
    return this.mapInstance.getIntersectGeometry(geometry1, geometry2);
  }
  /**
   * 判断相交
   * @param {Object<Geometry>} geometry1 图形
   * @param {Object<Geometry>} geometry2 图形
   * @returns {Boolean} 是否相交
   */
  isIntersect(geometry1, geometry2) {
    return this.mapInstance.isIntersect(geometry1, geometry2);
  }
  /**
   * 判断包含
   * @param {Object<Geometry>} outGeometry 图形(外)
   * @param {Object<Geometry>} inGeometry 图形(内)
   * @returns {Boolean} 是否包含
   */
  isContains(outGeometry, inGeometry) {
    return this.mapInstance.isContains(outGeometry, inGeometry);
  }
  /**
   * 获取图例信息
   * @param {String} url 查询服务url
   * @param {Function} hookCallbak 回调钩子函数,获取每项数据,可给每项数据添加属性
   * @returns Promise { [] }
   */
  getLayerLegend(url, hookCallbak) {
    if(MapClass.ClassType === "Arcgis") {
      return this.mapInstance.getLayerLegend(url, hookCallbak);
    }
    // 超图无法获取图例
    if(MapClass.ClassType === "Supermap") {
      return new Promise((resolve) => {
        resolve({});
      });
    }
  }
  /**
   * 获取图层信息
   * @param {String} url 查询服务url
   * @param {String} pipeType 管线类型,供水/排水
   * @returns Promise { layers: 图层数据,treeLayers:图层树结构 }
   */
  getLayersInfo(url, pipeType) {
    return this.mapInstance.getLayersInfo(url, pipeType);
  }
  /**
   * 
   * @param {String} url 查询服务url
   * @param {String} layerId 图层id 
   * @returns Promise { results: 结果集 }
   */
  getLayerFields(url, layerId) {
    return this.mapInstance.getLayerFields(url, layerId);
  }
  /**
   * 要素数据查询
   * @param {Object}
   * queryParams {
   *    url 查询服务url
   *    layerId 图层id 
   *    geometry 查询范围
   *    outFields 输出字段
   *    where 查询sql条件
   *    returnGeometry 是否返回空间信息
   *    pageNum 第几页
   *    pageSize 每页数据
   *    hookCallbak 回调钩子函数,获取每项数据,可给每项数据添加属性
   * }
   * @returns Promise { results: 结果集, total: 总数 }
   */
  queryFeatures(queryParams) {
    queryParams.where || (queryParams.where = "1=1");
    queryParams.outFields || (queryParams.outFields = ["*"]);
    queryParams.returnGeometry === undefined && (queryParams.returnGeometry = true);
    if(MapClass.ClassType === "Supermap") {
      queryParams.outFields = (queryParams.outFields.length === 1 && queryParams.outFields[0] === "*") ? null : queryParams.outFields;
      queryParams.queryOption = queryParams.returnGeometry ? "ATTRIBUTEANDGEOMETRY" : "ATTRIBUTE";
      // queryParams.fromIndex = (queryParams.pageNum - 1) * queryParams.pageSize;
      // queryParams.toIndex = queryParams.pageNum * queryParams.pageSize - 1;
      if(!queryParams.cancelPage) {
        queryParams.startRecord = queryParams.pageNum ? (queryParams.pageNum - 1) * queryParams.pageSize: 0;
        queryParams.expectCount = queryParams.pageSize || 10000;
      }
    }else if(MapClass.ClassType === "Arcgis") {
      if(!queryParams.cancelPage) {
        queryParams.start = queryParams.pageNum ? (queryParams.pageNum - 1) * queryParams.pageSize : 0;
        queryParams.num = queryParams.pageSize || 10000;
      }
    }
    return this.mapInstance.queryFeatures(queryParams);
  }
  /**
   * 空间数据查询
   * @param {Object}
   * queryParams {
   *    url 查询服务url
   *    layerIds 查询图层所有id
   *    geometry 查询范围
   *    returnGeometry 是否返回空间信息
   *    layerOption 供arcgis使用 top:查最上层,visible:查可见图层
   *    hookCallbak 回调钩子函数,获取每项数据,可给每项数据添加属性
   * }
   * @returns Promise { results: 结果集, total: 总数 }
   */
  identifyQuery(queryParams) {
    queryParams.returnGeometry === undefined && (queryParams.returnGeometry = true);
    if(MapClass.ClassType === "Supermap") {
      queryParams.queryOption = queryParams.returnGeometry ? "ATTRIBUTEANDGEOMETRY" : "ATTRIBUTE";
    }
    return this.mapInstance.identifyQuery(queryParams);
  }
  /**
   * 属性数据查询
   * @param {Object}
   * queryParams {
   *    url 查询服务url
   *    layerIds 查询图层所有id
   *    searchFields 查询范围
   *    searchText 搜索内容
   *    returnGeometry 是否返回空间信息
   *    hookCallbak 回调钩子函数,获取每项数据,可给每项数据添加属性
   * }
   * @returns Promise { results: 结果集, total: 总数 }
   */
  attributeQuery(queryParams) {
    queryParams.returnGeometry === undefined && (queryParams.returnGeometry = true);
    if(MapClass.ClassType === "Supermap") {
      queryParams.queryOption = queryParams.returnGeometry ? "ATTRIBUTEANDGEOMETRY" : "ATTRIBUTE";
    }
    return this.mapInstance.attributeQuery(queryParams);
  }
  /**
   * 获取图层字段的去重值(字段下拉数据)
   * @param {String} url 查询服务url (注:超图为dataUrl)
   * @param {String} layerId 查询图层id
   * @param {String} field 字段(与服务字段大小写一致)
   * @returns Promise { results: 结果集 }
   */
  getFieldDistinctValue(url, layerId, field) {
    return this.mapInstance.getFieldDistinctValue(url, layerId, field);
  }
  // 地图销毁释放地图资源
  destroyMap() {
    this.mapInstance.destroyMap();
  }
  /**
   * 坐标转换 https://www.npmjs.com/package/geotransform
   * @param {String} fromSR 转换前坐标系 'EPSG:4326 || GCJ02'
   * @param {String} toSR 转换后坐标系 'EPSG:3857'
   * @param {Array} coords 坐标值 [X, Y]
   * @returns {Array} 坐标值 [X, Y]
   */
  coordTransform(fromSR, toSR, coords) {
    return transform.coordTransform(fromSR, toSR, coords);
  }
  /**
   * 将epsg坐标转为地方四参坐标系
   * @param {Array} coordinate 
   * @returns {Array} 坐标值 [X, Y]
   */
  epsgToFourArgs(coords) {
    return transform.epsgToFourArgs(this.options.transformParam.fourArgsParams, coords);
  }
  /**
   * 将地方四参坐标系转为epsg坐标
   * @param {Array} coordinate 
   * @returns {Array} 坐标值 [X, Y]
   */
  fourArgsToEpsg(coords) {
    return transform.fourArgsToEpsg(this.options.transformParam.fourArgsParams, coords);
  }
}