import Layer from './Layer'
import { Zondy } from '../../../base'
import { defaultValue } from '../../../util'
/**
* 图层基类
* @classdesc 图层基类
* @class VectorTileLayer
* @moduleEX LayerModule
* @extends Layer
* @param {Object} options 构造参数
* @param {Number} [options.minScale = 1] 最小缩放级数
* @param {Number} [options.maxScale = 20] 最大缩放级数
* @param {String} [options.tokenKey = 'token'] token名
* @param {String} [options.tokenValue = undefined] token值
*/
class VectorTileLayer extends Layer {
constructor(options) {
super(options)
// eslint-disable-next-line no-param-reassign
options = defaultValue(options, {})
/**
* 最小层级
* @member {Number} VectorTileLayer.prototype.minScale
*/
this.minScale = defaultValue(options.minScale, 0)
/**
* 最大层级
* @member {Number} VectorTileLayer.prototype.maxScale
*/
this.maxScale = defaultValue(options.maxScale, 19)
/**
* token名
* @member {String} VectorTileLayer.prototype.tokenKey
*/
this.tokenKey = defaultValue(options.tokenKey, 'token')
/**
* token值
* @member {String} VectorTileLayer.prototype.tokenValue
*/
this.tokenValue = defaultValue(options.tokenValue, undefined)
/**
* 图层信息
* @readonly
* @member {TileInfo | undefined} VectorTileLayer.prototype.tileInfo
*/
this.tileInfo = undefined
}
/**
* @description 转换为json对象
* @return {Object} json对象
*/
toJSON() {
const json = super.toJSON()
if (json) {
json.minScale = this.minScale
json.maxScale = this.maxScale
json.tokenKey = this.tokenKey
json.tokenValue = this.tokenValue
}
return json
}
/**
* @description 克隆方法
* @return {Layer} 图层
*/
clone() {
return new Layer(this.toJSON())
}
}
Zondy.Layer.VectorTileLayer = VectorTileLayer
export default VectorTileLayer