# MapGIS Client for JavaScript API

Cesium MapboxGL Leaflet OpenLayers
API文档

    import VisualVariable from './VisualVariable'
    import { Zondy } from '../../../base'
    import { defaultValue } from '../../../util'
    import VisualVariableType from '../../../base/enum/VisualVariableType'
    import ColorStop from './support/ColorStop'

    /**
     * color视觉变量
     * @class ColorVariable
     * @moduleEX BaseModule
     * @param {Object} options 初始化参数
     * @param {String} [options.normalizationField] 归一化字段
     * @param {Array<ColorStop>} [options.stops] 颜色分段数组
     */
    class ColorVariable extends VisualVariable {
      constructor(options) {
        super(options)
        options = defaultValue(options, {})
        this.type = VisualVariableType.color
        /**
         * 归一化字段
         * @member {String} ColorVariable.prototype.normalizationField
         */
        this.normalizationField = defaultValue(options.normalizationField, '')
        /**
         * 归一化字段
         * @member {Array<ColorStop>} ColorVariable.prototype.stops
         */
        this.stops = defaultValue(options.stops, [])
        this.stops = this.stops.map((v) => ColorStop.fromJSON(v))
      }

      /**
       * 通过json构造ColorVariable对象
       * @return {ColorVariable} json对象
       * */
      static fromJSON(json) {
        return new ColorVariable(json)
      }

      /**
       * 导出为json对象
       * @return {Object} json对象
       * */
      toJSON() {
        const json = super.toJSON()
        json.type = this.type
        json.normalizationField = this.normalizationField
        json.stops = this.stops.map((v) => v.toJSON())
        return json
      }

      /**
       * 克隆对象
       * @return {ColorVariable} 克隆后的ColorVariable对象
       */
      clone() {
        return new ColorVariable(this.toJSON())
      }
    }

    Zondy.Renderer.VisualVariable.ColorVariable = ColorVariable
    export default ColorVariable

构造函数
成员变量
方法
事件