components/layer/videoLayer.js

/*``
 * @Author: lc
 * @Date:   2017-04-20 17:03:05
 * @Last Modified by:   hydata
 * @Last Modified time: 2018-05-10 17:12:17
 * @Email: 304861063@qq.com
 * @File Path: F:\work\hyMap\src\components\layer\buildingLayer.js
 * @File Name: clustersLayer.js
 * @Descript:加载视频文件图层
 */
import baseLayer from './baseLayer';
import styleModel from '../../model/videoStyle';

/**
 * 视频层
 * @extends base
 */
 class VideoLayer extends baseLayer {
    /**
     * 视频层
     * @param {*} options 
     */
    constructor(options) {

        options.layerType = 'video';
        super(options);
        options.serie.symbolStyle.normal=Object.assign({}, styleModel,  options.serie.symbolStyle.normal);
        this.data = options.serie;
        this.geojson = this.init(options.serie);

    }

    /**
     * 初始化
     * @param {*} serie 
     */
    init(serie) {

        //构建数据
        let source=serie.data;
        this.map.on('load', () => {

            this.map.addSource(this.id+'_sourceID', source);
            let clusterJson = this.buildJson(serie);
            this.addLayer(clusterJson);

        });



    }


    /**
     * 图层样式构建
     * @param serie
     * @returns {JSON}
     */
    
    buildJson(serie) {

        //构建样式
        let style = this.buildStyle(serie);
        let json = {
            'id': this.id,
            'source': this.id+'_sourceID'
        };
        Object.assign(json, style);
        return json;

    }


    /**图层样式
     * @param  {} serie
     * @returns {JSON}
     */
    buildStyle(serie) {

        let normal = Object.assign({}, serie.symbolStyle.normal);
        return {
            'paint': normal,
            'type': 'raster'
        };

    }
}
export default VideoLayer