core/layers/Geojson.js

import { addGeojson } from '../../utils/layers/Geojson'

/**
 * geojson主类
 * @class
 */
class Geojson {
  /**
   * 构造函数
   * @param {Object} viewer 地图场景对象
   */
  constructor(viewer) {
    this._viewer = viewer
  }
  /**
   * 加载geojson
   * @param {String} [url] - json地址
   * @param {String} [id] - 加载后图层id
   * @param {String} [type] - 加载类型,1-entity,2-primitive
   * @param {BillboardOption | PolylineOption | PolygonOption} [options=null] -图层参数设置,根据加载图层的几何类型,自主选择,点:{@link BillboardOption},线:{@link PolylineOption},面:{@link PolygonOption}
   * @returns {Promise<Entity | Primitive>} - 异步返回,加载后图层对象,Entity类或Primitive类对象,参考Cesium
   */
  async add(url, id, type, options) {
    const layer = await addGeojson(this._viewer, id, url, type, options)
    return layer
  }
}
export default Geojson