SuperMap iClient3D for WebGL动态标绘动画上传与下载

作者:kele

一、前言

动态标绘广泛应用于电力、通信和应急等多个行业和领域。它可以用形象生动的矢量符号描述各种业务对象,表示各种资源,还可以动态渲染业务进度和流程,下面将介绍如何保存和下载标绘动画。

二、数据准备

1.在webgl中使用动态标绘,首先需要通过iserver发布动态标绘服务
1).在iDesktop桌面软件安装目录下中找到JY.plot标绘文件
在这里插入图片描述
2).通过iserver发布动态标绘服务,选择JY.plot标绘文件
在这里插入图片描述
3).发布成功后,点进标绘服务,前端上传的态势图及动画都会存储到smllnfos节点下
在这里插入图片描述
2.接口介绍
一个完整的动画是由标绘符号(态势图)和动画过程组成,在动态标绘总控类中,动画对象和态势图对象是分开的,所以我们需要使用动画管理器对象和态势图管理器对象来共同实现动画的上传与下载
在这里插入图片描述

三、实现过程

1.创建标绘对象

serverUrl = 'http://localhost:8090/iserver/services/plot-JY/rest/plot';
plotting = cesium.Plotting.getInstance(serverUrl, scene);
plotEditControl = new cesium.PlotEditControl(scene, plottingLayer);//编辑控件
plotEditControl.activate();
animationManager = plotting.getGOAnimationManager();               //动画管理对象
sitDataManager = plotting.getSitDataManager();                     //态势图管理对象

2.创建动画,动画包括标绘符号(态势图)和动画过程

function creatAnimation() {
    var geoJGSZ = null,geoTFXS = null,geoLJXS = null,geoTFXS2 = null,geoZYSS = null,geoLJZY = null,geoZYSS2 = null,geoJC = null,geoSJ = null,geoLJJL = null,geoJGJL = null;
    var pointsJGSZ = [];
    pointsJGSZ[0] = new cesium.PlotPoint3D(13.0486416724835, 47.827217402435, 0);
    pointsJGSZ[1] = new cesium.PlotPoint3D(13.0484530291208, 47.8273069046719, 0);
    pointsJGSZ[2] = new cesium.PlotPoint3D(13.0498576145008, 47.8282734633643, 0);
    pointsJGSZ[3] = new cesium.PlotPoint3D(13.0513393769035, 47.8287206684327, 0);
    pointsJGSZ = MoveSymbol(pointsJGSZ);
    plottingLayer.createSymbol(22, 1004, pointsJGSZ, function (even) {
        geoJGSZ = even.feature;
        var goAnimationJGSZ = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_GROW, "JGSZ", geoJGSZ);//进攻警力生长动画
        goAnimationJGSZ.startTime = 0;//动画开始时间
        goAnimationJGSZ.duration = 5;//动画播放时长
    });
    var pointsTFXS = [];
    pointsTFXS[0] = new cesium.PlotPoint3D(13.0523705219875, 47.828610443775, 0);
    pointsTFXS[1] = new cesium.PlotPoint3D(13.0528881926318, 47.8282317961645, 0);
    pointsTFXS = MoveSymbol(pointsTFXS);
    plottingLayer.createSymbol(22, 1003, pointsTFXS, function (even) {
        geoTFXS = even.feature;
        geoTFXS.symbolStyle.lineColor = {red: 1, green: 1, blue: 0, alpha: 1};//"#ffff00"
        var goAnimationTFXS = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_SHOW, "TFXS1", geoTFXS);//逃犯显隐动画
        goAnimationTFXS.showEffect = false;//是否有显隐特效
        goAnimationTFXS.finalDisplay = true; //最终显示状态,默认不显示
        goAnimationTFXS.startTime = 0;
        goAnimationTFXS.duration = 6;
        var goAnimationTFXS1 = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_GROW, "TFSZ1", geoTFXS);//逃犯生长动画
        goAnimationTFXS1.startTime = 5;
        goAnimationTFXS1.duration = 6;
        goAnimationTFXS1.startScale = 1;//生长动画开始比例
        goAnimationTFXS1.endScale = 0;//生长动画结束比例
    });

    var pointsLJXS = [];
    pointsLJXS[0] = new cesium.PlotPoint3D(13.0534667673921, 47.8270362098687, 0);
    pointsLJXS[1] = new cesium.PlotPoint3D(13.0538011154244, 47.827160636473, 0);
    pointsLJXS[2] = new cesium.PlotPoint3D(13.0536234845445, 47.8277084980454, 0);
    pointsLJXS[3] = new cesium.PlotPoint3D(13.0527838234958, 47.8283098940719, 0);
    pointsLJXS = MoveSymbol(pointsLJXS);
    plottingLayer.createSymbol(421, 311, pointsLJXS, function (even) {
        geoLJXS = even.feature;
        var goAnimationLJXZ = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_SHOW, "LJXZ", geoLJXS);//拦截警力显隐动画
        goAnimationLJXZ.showEffect = false;
        goAnimationLJXZ.finalDisplay = true;
        goAnimationLJXZ.startTime = 0;
        goAnimationLJXZ.duration = 6;
        var goAnimationLJXZ1 = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_GROW, "LJXZ1", geoLJXS);//拦截警力生长动画
        goAnimationLJXZ1.startTime = 5;
        goAnimationLJXZ1.duration = 6;
    });
    var pointsTFXS2 = [];
    pointsTFXS2[0] = new cesium.PlotPoint3D(13.0523210258708, 47.8288491462176, 0);
    pointsTFXS2[1] = new cesium.PlotPoint3D(13.0529279851615, 47.8293174019239, 0);
    pointsTFXS2 = MoveSymbol(pointsTFXS2);
    plottingLayer.createSymbol(22, 1003, pointsTFXS2, function (even) {
        geoTFXS2 = even.feature;
        geoTFXS2._symbolStyle._lineColor = {red: 1, green: 1, blue: 0, alpha: 1};//"#ffff00"
        var goAnimationTFXS2 = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_SHOW, "TFXS2", geoTFXS2);//逃犯显隐动画
        goAnimationTFXS2.showEffect = false;
        goAnimationTFXS2.finalDisplay = true;
        goAnimationTFXS2.startTime = 0;
        goAnimationTFXS2.duration = 12;
        var goAnimationTFSZ2 = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_GROW, "TFSZ2", geoTFXS2);//逃犯生长动画
        goAnimationTFSZ2.startTime = 11;
        goAnimationTFSZ2.duration = 3;
        goAnimationTFSZ2.startScale = 0;
        goAnimationTFSZ2.endScale = 1;
    });
    var pointsZYSS = [];
    pointsZYSS[0] = new cesium.PlotPoint3D(13.0542650683879, 47.8287131454005, 0);
    pointsZYSS = MoveSymbol(pointsZYSS);
    plottingLayer.createSymbol(421, 80101, pointsZYSS, function (even) {
        geoZYSS = even.feature;
        geoZYSS.textContent = "支援警力";
        var goAnimationZYSS = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_BLINK, "ZYSS", geoZYSS);//支援警力闪烁动画
        goAnimationZYSS.blinkStyle = cesium.BlinkAnimationBlinkStyle.Blink_Frequency;//闪烁类型,频率闪烁
        goAnimationZYSS.replaceStyle = cesium.BlinkAnimationReplaceStyle.Replace_Color;//颜色交替类型
        goAnimationZYSS.startColor = {red:0,green:0,blue:1,alpha:1}; //开始颜色,默认为蓝色
        goAnimationZYSS.endColor =  {red:1,green:0,blue:0,alpha:1}; //结束颜色,默认为红色
        goAnimationZYSS.startTime = 14;
        goAnimationZYSS.duration = 3;
    });
    var pointsLJZY = [];
    pointsLJZY[0] = new cesium.PlotPoint3D(13.0532740180585, 47.829706145191, 0);
    pointsLJZY = MoveSymbol(pointsLJZY);
    plottingLayer.createSymbol(421, 80202, pointsLJZY, function (even) {
        geoLJZY = even.feature;
        geoLJZY.textContent = "拦截车";

        var goAnimationJGZY = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_BLINK, "JGZY", geoLJZY);//拦截车闪烁动画
        goAnimationJGZY.blinkStyle = cesium.BlinkAnimationBlinkStyle.Blink_Frequency;
        goAnimationJGZY.replaceStyle = cesium.BlinkAnimationReplaceStyle.Replace_Color;
        goAnimationJGZY.startTime = 14;
        goAnimationJGZY.duration = 3;
    });
    var pointsZYSS2 = [];
    pointsZYSS2[0] = new cesium.PlotPoint3D(13.0520708307129, 47.8299387619131, 0);
    pointsZYSS2 = MoveSymbol(pointsZYSS2);
    plottingLayer.createSymbol(421, 80101, pointsZYSS2, function (even) {
        geoZYSS2 = even.feature;
        geoZYSS2.textContent = "支援警力";

        var goAnimationZYSS2 = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_BLINK, "ZYSS2", geoZYSS2);//支援警力闪烁动画
        goAnimationZYSS2.blinkStyle = cesium.BlinkAnimationBlinkStyle.Blink_Frequency;
        goAnimationZYSS2.replaceStyle = cesium.BlinkAnimationReplaceStyle.Replace_Color;
        goAnimationZYSS2.startTime = 14;
        goAnimationZYSS2.duration = 3;
    });
    var pointsJC = [];
    pointsJC[0] = new cesium.PlotPoint3D(13.0523196095789, 47.8276819225323, 0);
    pointsJC = MoveSymbol(pointsJC);
    plottingLayer.createSymbol(421, 50, pointsJC, function (even) {
        geoJC = even.feature;
        geoJC.symbolStyle.surroundLineType = 1;//衬线
        geoJC.textContent = "路卡";
        var goAnimationJC = animationManager.createGOAnimation(cesium.GOAnimationType.ANIMATION_SCALE, "JC", geoJC);
        goAnimationJC.startTime = 0;
        goAnimationJC.duration = 3;
    });
    var pointsSJ = [];
    pointsSJ[0] = new cesium.PlotPoint3D(13.0522206845731, 47.8287075057692, 0);
    pointsSJ = MoveSymbol(pointsSJ);
    plottingLayer.createSymbol(421, 20100, pointsSJ, function (even) {
        geoSJ = even.feature;
        geoSJ.symbolStyle.lineColor = {red: 1, green: 1, blue: 0, alpha: 1};//"#ffff00"
        geoSJ.textContent = "事件";
    });
    var pointsLJJL = [];
    pointsLJJL[0] = new cesium.PlotPoint3D(13.053414647609, 47.8268751538344, 0);
    pointsLJJL = MoveSymbol(pointsLJJL);
    plottingLayer.createSymbol(421, 9, pointsLJJL, function (even) {
        geoLJJL = even.feature;
        geoLJJL.textContent = "拦截警力";
    });
    var pointsJGJL = [];
    pointsJGJL[0] = new cesium.PlotPoint3D(13.0485470948225, 47.8271255667932, 0);
    pointsJGJL = MoveSymbol(pointsJGJL);
    plottingLayer.createSymbol(421, 9, pointsJGJL, function (even) {
        geoJGJL = even.feature;
        geoJGJL.textContent = "进攻警力";
    });
}

在这里插入图片描述
3.将创建好的态势图及动画上传到iServer

//上传动画
animationManager.saveEvoFile("dh01", true)
//上传态势图
sitDataManager.saveSmlFile();

上传之后,在动态标绘服务中会生成对应文件
在这里插入图片描述
4.下载态势图及动画

//下载态势图
function clickTreeNode(clickSmlFileName) {
    var result = sitDataManager.downloadSmlFileUrl(clickSmlFileName);
    document.getElementById("downloadUrl").value = serverUrl + result;
    document.getElementById("smlFileName").value = clickSmlFileName;
    sitDataManager.openSmlFileOnServer(clickSmlFileName);
}
//下载动画
animationManager.openEvoFileOnServer("dh01")

在这里插入图片描述
刷新页面后,从iServer中下载态势图和动画,点击播放即可展示完整动画。
demo下载地址:https://pan.baidu.com/s/1EmW_-XmpDUZpjIV_znkA4Q
提取码:rv8i

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值