import Layer from './Layer'
import { defaultValue } from '../../../util'
import { Zondy } from '../../../base'
/**
* 场景图层基类
* @class SceneLayer
* @moduleEX LayerModule
* @extends Layer
* @param {Object} options 构造参数
* @param {String} [options.url] 服务基地址
* @param {String} [options.tokenKey = 'token'] token名
* @param {String} [options.tokenValue] token值,只有当tokenValue存在时,才会绑定token
*/
class SceneLayer extends Layer {
constructor(options) {
super(options)
options = defaultValue(options, {})
/**
* 服务基地址
* @member {String} SceneLayer.prototype.url
*/
this.url = defaultValue(options.url, undefined)
/**
* token名
* @member {String} SceneLayer.prototype.tokenKey
*/
this.tokenKey = defaultValue(options.tokenKey, 'token')
/**
* token值
* @member {String} SceneLayer.prototype.tokenValue
*/
this.tokenValue = defaultValue(options.tokenValue, undefined)
}
/**
* @description 转换为json对象
* @return {Object} json对象
*/
toJSON() {
const json = super.toJSON()
json.url = this.url
json.tokenKey = this.tokenKey
json.tokenValue = this.tokenValue
return json
}
/**
* @description 克隆方法
* @return {SceneLayer} 图层
*/
clone() {
return new SceneLayer(this.toJSON())
}
}
Zondy.Layer.SceneLayer = SceneLayer
export default SceneLayer