0

1、我想要在一系列的位置批量增加标签,应该怎么弄?
2、增加完标签之后,我想让他显示、隐藏、偏移、放大、缩小等操作?

陆剑伟 141
2017-09-21 提问
1 个回答
0

//1、获取插入标签的坐标列表,可由传感器提供
//2、插入标签
//3、处理图标

var tagArr = [];
//定义位置坐标
var position0=new Object();
position0={"x":36633.77540744109,"y":25877.296549886843,"z":3430.030510986958};
var position1=new Object();
position1={"x":-8419.91826599704,"y":18683.906725696797,"z":-0.00003898915679201309};
var position2=new Object();
position2={"x":7753.682197661594,"y":26165.77267540693,"z":-0.0000389886984066834};
var position3=new Object();
position3={"x":-2614.5497202407423,"y":27124.343554106745,"z":-0.000038988625192359905};
var positions=[];
positions.push(position0);
positions.push(position1);
positions.push(position2);
positions.push(position3);

//导入标签
function addpic(){

// 首先创建DrawableContainer
drawaleContainerConfig = new Glodon.Bimface.Plugins.Drawable.DrawableContainerConfig();
drawaleContainerConfig.viewer = viewer;
drawableContainer = new Glodon.Bimface.Plugins.Drawable.DrawableContainer(drawaleContainerConfig);    
for(i=0;i<positions.length;i++)
    {
        imageConfig = new Glodon.Bimface.Plugins.Drawable.ImageConfig();
        //设置image的路径
        imageConfig.src="fire.gif";
        imageConfig.worldPosition = positions[i];
        image = new Glodon.Bimface.Plugins.Drawable.Image(imageConfig);
        //设置image的id
        image.id="image"+i;
        //可以设置图片的偏移量
        image.setOffsetX(100);
        image.setOffsetY(100);
        image.setWidth(80);
        image.setHeight(100);    
        tagArr.push(image);            
        // //设置image的click事件
        image.onClick(function() {
            console.log(this.id);
        });
        // 添加image
        drawableContainer.addItems(tagArr);
        //渲染模型
        viewer.render();                            
        }
    }

}

可借鉴:如何在二三维视图上打标签

图片描述

撰写答案

你可能感兴趣的

推广链接