类名 common/base/WMTSStyle.js
import Zondy from './Zondy'
import { defaultValue, getGUID } from '../util'

/**
 * IGS地图服务图层
 * @class WMTSStyle
 * @classdesc IGS地图图层
 * @param {Object} options 构造参数
 * @param {String} [options.description = undefined] 样式描述
 * @param {String} [options.id = getGUID()] WMTS样式id
 * @param {String} [options.isDefault = false] 是否为默认样式
 * @param {WMTSLayer} [options.title = undefined] 样式标题
 */

class WMTSStyle {
  constructor(options) {
    options = defaultValue(options, {})
    /**
     * 样式描述
     * @member {String} WMTSStyle.prototype.description
     */
    this.description = defaultValue(options.description, undefined)
    /**
     * WMTS样式id
     * @member {String} WMTSStyle.prototype.id
     */
    this.id = defaultValue(options.id, getGUID())
    /**
     * 是否为默认样式
     * @member {Boolean} WMTSStyle.prototype.isDefault
     */
    this.isDefault = defaultValue(options.isDefault, false)
    /**
     * 样式标题
     * @member {WMTSLayer} WMTSStyle.prototype.title
     */
    this.title = defaultValue(options.title, undefined)
  }

  /**
   * @function WMTSStyle.prototype.fromJSON
   * @description 将JSON格式的WMTS样式参数转换为JS对象
   * @param {Object} json WMTS样式的实例化JSON
   */
  fromJSON(json) {
    json = defaultValue(json, {})

    this.description = defaultValue(json.description, undefined)
    this.id = defaultValue(json.id, getGUID())
    this.isDefault = defaultValue(json.isDefault, false)
    this.title = defaultValue(json.title, undefined)
  }

  /**
   * @function WMTSStyle.prototype.toJSON
   * @description 将JS对象转换为JSON格式
   * @returns {Object} WMTS样式的实例化JSON
   */
  toJSON() {
    return {
      description: this.description,
      id: this.id,
      isDefault: this.isDefault,
      title: this.title
    }
  }

  /**
   * 克隆WMTS样式对象
   * @return {WMTSStyle} 克隆后的WMTS样式对象
   */
  clone() {
    return new WMTSStyle(this.toJSON())
  }
}

Zondy.WMTSStyle = WMTSStyle
export default WMTSStyle
构造函数
成员变量
方法
事件