2.5.7 实时路径漫游
实时路径漫游
实时路径漫游是动态路径漫游的一种模式。它可以在播放的过程中删除关键点列表前端的点以及在列表的后端追加关键点,但不影响路径的播放。
由于是实时路径漫游是属于动态路径漫游中的一种,对于图层的创建以及编辑,可以参考动态路径漫游,这里只介绍实时路径漫游特有的一些操作。实时路径漫游主要包括以下几种特有的操作。
- 创建图层。 这与动态路径漫游的创建大体相同,只是在设置播放模式时,
PlayerMode
必须设为PLAYER_ONEWAY_STAY
。 即实时播放。 - 改变关键点容量。 通过更新
KeyPointCapacity
参数可设置最大存储关键点数量,默认为-1,代表不限容量。当设定一个容量时,如果关键点数量超出该容量,在播放的过程中,会自动剔除已经播放的关键点。 - 剔除关键点。 在播放的过程中,也可以手动剔除已经播放的关键点。通过更新图层操作将
OperationName
参数设为PopKeyPoint
, 然后设置PopSize
参数的数量,可以删除已经播放的关键点个数。 - 追加关键点。 可以在关键点末尾进行关键点的追加。通过更新图层操作将
OperationName
参数设为AppendKeyPoints
, 然后在KeyPoints
参数中设置追加的关键点集,即可实现关键点的追加。
实时路径漫游主要用于模拟GPS实时跟踪效果模拟。在播放的过程中,定时接收GPS传递的关键点信息,然后通过追加关键点操作让路径一直延伸。
注意: 如果关键点都已经播放完毕,在进行追加关键点操作之前,路径会暂停等待,直到有新的关键点追加进来,路径才会继续播放。
下图是开启实时路径播放的效果:
代码调用示例
Javascript调用
var event = null;
var dynamicPathLayer = null;
var preSetPoint = "";
var bIsFollow = true;
var bIsVisible = true;
var speed = 3;
var pickIndex = null;
var indexSize = 0;
var keyPointList = "120.219652381,30.2102796597,14.8471973008;120.219228677,30.2109204111,14.7999731209;120.219066611,30.2109525583,14.7999699935;120.218700324,30.2108002945,14.799943476;120.218728451,30.2106748092,14.7999742515;120.218952979,30.2100989073,14.7999547897;120.219026376,30.2098925768,14.799970909;120.218995824,30.2098632529,14.8299724646;120.218730274,30.2097854181,14.7999352217;";
var keyPointList1="120.218328549,30.2096756449,14.7999559836;120.218147335,30.2098795979,14.7999707833;120.217900502,30.210294582,14.7999698296;";
//回调实现函数
function callBackFun(layerId, type){
var info = String(layerId).split('|');//SDKv6.1信息格式:直接为数字 SDKv6.2信息格式:MapViewId:0|LayerId:7
var id = layerId;
if(info.length >= 2){
id = info[1].substring(8);
}
if(dynamicPathLayer.GetLayerID() == layerId || dynamicPathLayer.GetLayerID() == id){
//console.log(position);
}
}
//*************************************************************************
//创建路径图层
//*************************************************************************
//创建路径图层
function AddDynamicPathLayer()
{
if(dynamicPathLayer == null){
var tlo = map.CreateLayerOptions("dynamicpathlayer"); // 创建路径动画图层配置,给配置起个名称,任意名称
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions"); // 创建配置类型,
//模型路径配置配置
tlo.AddConfig("Url", gModelDeviceFolderPath+"/car.wrl"); //配置的动画的模型
tlo.AddConfig("NodeXScale", "0.5"); //模型x轴缩放大小
tlo.AddConfig("NodeYScale", "0.5"); //模型Y轴缩放大小
tlo.AddConfig("NodeZScale", "0.5"); //模型Z轴缩放大小
tlo.AddConfig("ModelRoll", "0"); //模型x轴旋转配置
tlo.AddConfig("ModelPitch", "3.116"); //模型Y轴旋转配置
tlo.AddConfig("ModelHeading", "0"); //模型Z轴旋转配置
tlo.AddConfig("ModelLiftUp", "0.1"); //模型相对于关键点抬高
tlo.AddConfig("PlayerMode", "PLAYER_ONEWAY_STAY");//播放模式 有一次性播放"PLAYER_ONEWAY" 循环一次播放"PLAYER_ONEWAY_LOOP" 往返播放"PLAYER_ROUND_LOOP" 实时播放"PLAYER_ONEWAY_STAY"
tlo.AddConfig("PlayerState", "PLAYER_STOP"); //播放状态 有播放"PLAYER_PLAY"、暂停"PLAYER_PAUSE"、停止"PLAYER_STOP"
tlo.AddConfig("ViewObjectMode", "0,-0.3,3"); //设置视角
tlo.AddConfig("Velocity", "15.0"); ///速度 单位m/s
tlo.AddConfig("CornerSpeedScale", "0.3"); ///转角速度比例(0-1之间)
tlo.AddConfig("LineWidth", "2.0"); ///线宽(0-10)
tlo.AddConfig("LineStipple", "65535"); ///线样式
tlo.AddConfig("LineColor", "1.0,1.0,0.0,1"); //路径线颜色
tlo.AddConfig("Radius", "3.0"); //拐弯处平滑半径(圆角)
tlo.AddConfig("KeyPoints",keyPointList); //导入关键点列表
tlo.AddConfig("InterpLineWidth", "4.0"); ///差值线 线宽(0-10)
tlo.AddConfig("InterpLineStipple", "500"); ///差值线线样式
tlo.AddConfig("InterpLineColor", "1.0,1.0,1.0,1.0"); //差值线颜色,不需要差值线去掉颜色
tlo.AddConfig("KeyPointLiftUp", "0"); //关键点抬高
tlo.AddConfig("PlayAsKeyPoint", "false"); //true为按关键点参数播放,false为统一按路径删除播放
tlo.AddConfig("IsOnGround", "false"); //是否将视点保持在地面以上
tlo.AddConfig("IsSwerveControl", "true"); //是否弯道减速/加速
//tlo.AddConfig("PathActive", "true"); //路径激活状态,与节点激活状态互斥
tlo.AddConfig("NodeActive", "false"); //节点激活状态,当为true时可以跟随模型或路径移动,当前漫游不可用
dynamicPathLayer = map.CreateLayer("DynamicPathLayer", tlo);
map.AddLayer(dynamicPathLayer);
dynamicPathLayer.AddObserver();
}
}
//删除路径动画或漫游
function RemoveDynamicPathLayer() {
if(dynamicPathLayer){
map.RemoveLayer(dynamicPathLayer);//删除图层
dynamicPathLayer = null;
}
}
//改变关键点容量,超出容量会删除序列最前的关键点
function UpdateDynamicPathPointsCapacity()
{
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("KeyPointCapacity", "5"); //设置关键点容量
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//剔除首个关键点
function RemoverFirstPoint()
{
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("OperationName","PopKeyPoint");//实时剔除关键点
tlo.AddConfig("PopSize", "1"); //剔除关键点个数
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//末尾添加关键点
function AddEndPoint()
{
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("OperationName","AppendKeyPoints");//实时添加末尾关键点
tlo.AddConfig("KeyPoints",keyPointList1);//末尾添加关键点
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//设置路径显示
function SetVisibleRoamPathTrue() {
if(dynamicPathLayer){
dynamicPathLayer.SetVisible(true);//设置路径显示
}
}
//设置路径隐藏
function SetVisibleRoamPathFalse() {
if(dynamicPathLayer){
dynamicPathLayer.SetVisible(false);//设置路径隐藏
}
}
//播放
function Play() {
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_PLAY");//设置播放模式为播放
tlo.AddConfig("Velocity", "30.0");//速度
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//暂停
function Pause() {
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_PAUSE");//暂停
tlo.AddConfig("Velocity", "20.0");//速度
tlo.AddConfig("LineColor", "1.0,0.0,0.0,1"); //路径线颜色
tlo.AddConfig("InterpLineColor", "1.0,1.0,0,1"); //插值线颜色
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//停止
function Stop() {
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_STOP");
tlo.AddConfig("LineColor", "0.0,1.0,0.0,1"); //路径线颜色
tlo.AddConfig("InterpLineColor", "0.0,1.0,1.1,0"); //插值线颜色
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//跟随模型或路径移动,漫游不可用
//当做更新操作时,只需把需要更新的参数构建更新配置参数就可以,不需要更新的参数不需要在设置
function UpdateNodeActive() {
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");/////////创建更新的配置参数
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("NodeActive", "true");//路径跟随
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
//停止跟随模型或路径移动,漫游可用
function CancelUpdateNodeActive() {
if(dynamicPathLayer){
var tlo = map.CreateLayerOptions("dynamicpathlayer");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("NodeActive", "false");//路径不跟随
dynamicPathLayer.UpdateLayerOptions(tlo);
}
}
C++调用
BaseObjectCOMLib::ILayerObjectPtr dynamicPathLayer;//路径图层对象
//加载路径图层,参数:是否加载模型,是否预设点位,动画模型路径,关键点列表
BaseObjectCOMLib::ILayerObjectPtr Cf4c6DynamicPathForRealTimeDlg::loadDynamicPathLayer(bool bIsModel,bool bIsPreset,std::string gModelDeviceFolderPath,std::string keyPointList)
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");//创建配置类型,
if(bIsModel){//模型路径配置配置
tlo->AddConfig("Url", gModelDeviceFolderPath.c_str()); //配置的动画的模型
tlo->AddConfig("NodeXScale", "0.5");//模型x轴缩放大小
tlo->AddConfig("NodeYScale", "0.5");//模型Y轴缩放大小
tlo->AddConfig("NodeZScale", "0.5");//模型Z轴缩放大小
tlo->AddConfig("ModelRoll", "0");//模型x轴旋转量
tlo->AddConfig("ModelPitch", "3.116");//模型Y轴旋转量
tlo->AddConfig("ModelHeading", "0");//模型Z轴旋转量
}
tlo->AddConfig("PlayerMode", "PLAYER_ONEWAY_STAY");//播放模式. PLAYER_ONEWAY-播放一次; PLAYER_ONEWAY_LOOP-循环播放; PLAYER_ROUND_LOOP-往返播放; PLAYER_ONEWAY_STAY-实时播放
tlo->AddConfig("PlayerState", "PLAYER_STOP");//播放状态. PLAYER_PLAY-播放; PLAYER_PAUSE-暂停; PLAYER_STOP停止
tlo->AddConfig("ViewObjectMode", "0,-0.2,3");//设置视角对象;视角对象的格式为"水平方位角,垂直俯仰角,视点到关键点距离"
tlo->AddConfig("Velocity", "10");//速度. 单位m/s
tlo->AddConfig("Accelerator", "0.0");//加速度. 单位m/s,加速度大于0会进行加速行驶
tlo->AddConfig("CornerSpeedScale", "0.5");//转角速度比例(0-1之间)
tlo->AddConfig("LineWidth", "2.0");//线宽(0-10)
tlo->AddConfig("LineStipple", "-1");//线样式
tlo->AddConfig("LineColor", "1.0,1.0,0.0,1");//路径线颜色
tlo->AddConfig("Radius", "3.0");//拐弯处平滑半径(圆角)
if(bIsPreset){
tlo->AddConfig("KeyPoints", keyPointList.c_str());//输入关键点列表
}
tlo->AddConfig("InterpLineWidth", "2.0");//差值线线宽(0-10)
tlo->AddConfig("InterpLineStipple", "500");//差值线线样式
tlo->AddConfig("InterpLineColor", "1.0,1.0,1.0,1.0");//差值线颜色,不需要差值线去掉颜色
tlo->AddConfig("KeyPointLiftUp", "0"); //关键点抬高
tlo->AddConfig("PlayAsKeyPoint", "false");//播放类型。true-以关键点参数进行播放;false-以路径参数进行播放
tlo->AddConfig("IsSwerveControl", "true");//是否弯道减速,需配合CornerSpeedScale来使用
tlo->AddConfig("NodeActive", "false");//跟随移动状态。true-跟随移动;false-不跟随
BaseObjectCOMLib::ILayerObjectPtr dynamicPathLayer = map->CreateLayer("DynamicPathLayer", tlo);//创建路径图层
map->AddLayer(dynamicPathLayer);//添加图层
dynamicPathLayer->AddObserver();//添加路径图层监视
return dynamicPathLayer;
}
//创建路径图层
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedAdddynamicpathlayer()
{
if(dynamicPathLayer)
{
return;
}
char temp_status[MAX_PATH];
GetPrivateProfileStringA("Path", "ModelDeviceFolderPath", "", temp_status, MAX_PATH, mIniPath.c_str());
std::string ModelPath(temp_status);
dynamicPathLayer = loadDynamicPathLayer(TRUE,TRUE, ModelPath, "120.219652381,30.2102796597,14.8471973008;120.219228677,30.2109204111,14.7999731209;120.219066611,30.2109525583,14.7999699935;120.218700324,30.2108002945,14.799943476;120.218728451,30.2106748092,14.7999742515;120.218952979,30.2100989073,14.7999547897;120.219026376,30.2098925768,14.799970909;120.218995824,30.2098632529,14.8299724646;120.218730274,30.2097854181,14.7999352217;");//加载路径图层
}
//改变关键点容量
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedUpdatedynamicpathpointscapacity()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("KeyPointCapacity", "5"); //设置关键点容量
dynamicPathLayer->UpdateLayerOptions(tlo);//更新路径图层
}
//实时剔除首点
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedRemoverfirstpoint()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("OperationName","PopKeyPoint");//实时剔除关键点
tlo->AddConfig("PopSize", "1"); //剔除关键点个数
dynamicPathLayer->UpdateLayerOptions(tlo);//更新路径图层
}
//实时添加末点
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedAddendpoint()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("OperationName","AppendKeyPoints");//实时添加末尾关键点
tlo->AddConfig("KeyPoints","120.218328549,30.2096756449,14.7999559836;120.218147335,30.2098795979,14.7999707833;120.217900502,30.210294582,14.7999698296;");//末尾添加关键点
dynamicPathLayer->UpdateLayerOptions(tlo);//更新路径图层
}
//删除路径漫游
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedRemovedynamicpathlayer()
{
map->RemoveLayer(dynamicPathLayer);//删除图层
}
//跟随移动
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedUpdatenodeactive()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("NodeActive", "true");//路径跟随
dynamicPathLayer->UpdateLayerOptions(tlo);//更新路径图层
}
//取消跟随移动
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedCancelupdatenodeactive()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("NodeActive", "false");//路径不跟随
dynamicPathLayer->UpdateLayerOptions(tlo);//更新路径图层
}
//播放
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedPlay()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("PlayerState", "PLAYER_PLAY");//设置播放模式为播放
dynamicPathLayer->UpdateLayerOptions(tlo);
}
//暂停
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedPause()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("PlayerState", "PLAYER_PAUSE");//设置播放模式为暂停
dynamicPathLayer->UpdateLayerOptions(tlo);
}
//停止
void Cf4c6DynamicPathForRealTimeDlg::OnBnClickedStop()
{
ConfigOptionsCOMLib::ILayerOptionsPtr tlo = (ConfigOptionsCOMLib::ILayerOptionsPtr)map->CreateLayerOptions(""); //创建图层配置对象,任意名称
tlo->AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo->AddConfig("PlayerState", "PLAYER_STOP");//设置播放模式为停止
dynamicPathLayer->UpdateLayerOptions(tlo);
}
C#调用
ILayerObject dynamicPathLayer;//路径图层对象
string gModelDeviceFolderPath = "E:\data\LocalData\Other\models";
//创建路径图层
private void AddDynamicPathLayer_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions(""); // 创建路径动画图层配置,给配置起个名称,任意名称
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions"); // 创建配置类型,
//模型路径配置配置
tlo.AddConfig("Url", gModelDeviceFolderPath + "/car.wrl"); //配置的动画的模型
tlo.AddConfig("NodeXScale", "0.5"); //模型x轴缩放大小
tlo.AddConfig("NodeYScale", "0.5"); //模型Y轴缩放大小
tlo.AddConfig("NodeZScale", "0.5"); //模型Z轴缩放大小
tlo.AddConfig("ModelRoll", "0"); //模型x轴旋转配置
tlo.AddConfig("ModelPitch", "3.116"); //模型Y轴旋转配置
tlo.AddConfig("ModelHeading", "0"); //模型Z轴旋转配置
tlo.AddConfig("ModelLiftUp", "0.1"); //模型相对于关键点抬高
tlo.AddConfig("PlayerMode", "PLAYER_ONEWAY_STAY");//播放模式 有一次性播放"PLAYER_ONEWAY" 循环一次播放"PLAYER_ONEWAY_LOOP" 往返播放"PLAYER_ROUND_LOOP" 实时播放"PLAYER_ONEWAY_STAY"
tlo.AddConfig("PlayerState", "PLAYER_STOP"); //播放状态 有播放"PLAYER_PLAY"、暂停"PLAYER_PAUSE"、停止"PLAYER_STOP"
tlo.AddConfig("ViewObjectMode", "0,-0.3,3"); //设置视角
tlo.AddConfig("Velocity", "15.0"); ///速度 单位m/s
tlo.AddConfig("CornerSpeedScale", "0.3"); ///转角速度比例(0-1之间)
tlo.AddConfig("LineWidth", "2.0"); ///线宽(0-10)
tlo.AddConfig("LineStipple", "65535"); ///线样式
tlo.AddConfig("LineColor", "1.0,1.0,0.0,1"); //路径线颜色
tlo.AddConfig("Radius", "3.0"); //拐弯处平滑半径(圆角)
tlo.AddConfig("KeyPoints", "120.219652381,30.2102796597,14.8471973008;120.219228677,30.2109204111,14.7999731209;120.219066611,30.2109525583,14.7999699935;120.218700324,30.2108002945,14.799943476;120.218728451,30.2106748092,14.7999742515;120.218952979,30.2100989073,14.7999547897;120.219026376,30.2098925768,14.799970909;120.218995824,30.2098632529,14.8299724646;120.218730274,30.2097854181,14.7999352217;"); //导入关键点列表
tlo.AddConfig("InterpLineWidth", "4.0"); ///差值线 线宽(0-10)
tlo.AddConfig("InterpLineStipple", "500"); ///差值线线样式
tlo.AddConfig("InterpLineColor", "1.0,1.0,1.0,1.0"); //差值线颜色,不需要差值线去掉颜色
tlo.AddConfig("KeyPointLiftUp", "0"); //关键点抬高
tlo.AddConfig("PlayAsKeyPoint", "false"); //true为按关键点参数播放,false为统一按路径删除播放
tlo.AddConfig("IsOnGround", "false"); //是否将视点保持在地面以上
tlo.AddConfig("IsSwerveControl", "true"); //是否弯道减速/加速
//tlo.AddConfig("PathActive", "true"); //路径激活状态,与节点激活状态互斥
tlo.AddConfig("NodeActive", "false"); //节点激活状态,当为true时可以跟随模型或路径移动,当前漫游不可用
dynamicPathLayer = map.CreateLayer("DynamicPathLayer", tlo);
map.AddLayer(dynamicPathLayer);
dynamicPathLayer.AddObserver();
}
//改变关键点容量,超出容量会删除序列最前的关键点
private void UpdateDynamicPathPointsCapacity_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("KeyPointCapacity", "5"); //设置关键点容量
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//剔除首个关键点
private void RemoverFirstPoint_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("OperationName", "PopKeyPoint");//实时剔除关键点
tlo.AddConfig("PopSize", "1"); //剔除关键点个数
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//末尾添加关键点
private void AddEndPoint_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("OperationName", "AppendKeyPoints");//实时添加末尾关键点
tlo.AddConfig("KeyPoints", "120.218328549,30.2096756449,14.7999559836;120.218147335,30.2098795979,14.7999707833;120.217900502,30.210294582,14.7999698296;");//末尾添加关键点
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//删除路径动画或漫游
private void RemoveDynamicPathLayer_Click(object sender, EventArgs e)
{
map.RemoveLayer(dynamicPathLayer);//删除图层
dynamicPathLayer = null;
}
//跟随模型或路径移动,漫游不可用
//当做更新操作时,只需把需要更新的参数构建更新配置参数就可以,不需要更新的参数不需要在设置
private void button1_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");/////////创建更新的配置参数
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("NodeActive", "true");//路径跟随
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//停止跟随模型或路径移动,漫游可用
private void CancelUpdateNodeActive_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("NodeActive", "false");//路径不跟随
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//设置路径显示
private void SetVisibleRoamPathTrue_Click(object sender, EventArgs e)
{
dynamicPathLayer.SetVisible(true);//设置路径显示
}
//设置路径隐藏
private void SetVisibleRoamPathFalse_Click(object sender, EventArgs e)
{
dynamicPathLayer.SetVisible(false);//设置路径隐藏
}
//播放
private void Play_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_PLAY");//设置播放模式为播放
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//暂停
private void Pause_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_PAUSE");//暂停
dynamicPathLayer.UpdateLayerOptions(tlo);
}
//停止
private void Stop_Click(object sender, EventArgs e)
{
var tlo = map.CreateLayerOptions("");
tlo.AddConfig("LayerOptionsName", "DynamicPathLayerOptions");
tlo.AddConfig("PlayerState", "PLAYER_STOP");
dynamicPathLayer.UpdateLayerOptions(tlo);
}