Skip to content

打标绘点

(以标注为例)

Javascript
var handler11 = new LSGlobe.ScreenSpaceEventHandler(viewer.scene.canvas);
handler11.setInputAction(function (movement) {
        //获取的坐标上添加标绘点,具体的坐标获取参照坐标转换
        var Pos = scene.pickGlobe(movement.position);
        viewer.entities.add({
            //标注的坐标 x,y,z 经度纬度和高度的值
            position: new LSGlobe.Cartesian3(Pos.x, Pos.y, Pos.z),
            label: {
                text: "标注",
                //标注文字描述
                font: "32px Microsoft YaHei",
                //标注文字大小、字体
                style: LSGlobe.LabelStyle.FILL_AND_OUTLINE,
                outlineWidth: 6,
                translucencyByDistance: new LSGlobe.NearFarScalar(1.5e2, 1.0, 1.5e5, 0.0),
                //根据告诉改变透明度
                horizontalOrigin: LSGlobe.HorizontalOrigin.LEFT,
                pixelOffset: new LSGlobe.Cartesian2(15, -15),
                disableDepthTestDistance: 0,
                //标注的遮挡距离设置为100则视角与标注的距离大于100米时会有遮挡
                scale: 0.5
            },
            billboard: {
                image: "http://uatonline.wish3d.com/GEMarker/1.png",
                //标注图标路径
                width: 64,
                height: 64,
                disableDepthTestDistance: 0,
                //标注的遮挡距离设置为100则视角与标注的距离大于100米时会有遮挡
                scale: 0.5,
                translucencyByDistance: new LSGlobe.NearFarScalar(1.5e2, 1.0, 1.5e5, 0.0),
            },
            //标注唯一标识
            show: true //标绘点对象的true显示,false隐藏属性
        });
    },
    LSGlobe.ScreenSpaceEventType.LEFT_CLICK)

Released under the MIT License.