鼠标选择实体-源代码示例 运行 重置

                    <!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8' />
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no'/>
    <link href='http://bigemap.com:9000/bigemap-gl.js/v1.1.0/Widgets/widgets.css' rel='stylesheet'/>
    <script src='http://bigemap.com:9000/bigemap-gl.js/v1.1.0/bigemap-gl.js'></script>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #container {
            position: absolute;
            top: 0;
            bottom: 0;
            width: 100%;
        }
        #result{
            position: absolute;
            left: 50px;
            top:10px;
            z-index: 999;
            width: 130px;
            background-color: #eee;
            padding: 5px 10px;
        }
        .bmgl-widget-credits{display:none}
    </style>
    <title>part_test</title>
</head>
<body>
<div id="result">当前选中 :</div>
<div id='container'></div>
<script>
    bmgl.Config.HTTP_URL = 'http://bigemap.com:9000';
    var viewer = new bmgl.Viewer('container', {mapId: 'bigemap.googlemap-satellite',requestRenderMode:false});
    //取消默认的点击事件
    viewer.screenSpaceEventHandler.removeInputAction(bmgl.ScreenSpaceEventType.LEFT_CLICK);
    //禁止默认的地形遮挡
    viewer.scene.globe.depthTestAgainstTerrain=false;
    var handler=new bmgl.ScreenSpaceEventHandler(viewer.canvas);
    handler.setInputAction(function (e) {
        var entity=viewer.scene.pick(e.position);
        if (entity){
            document.getElementById('result').innerHTML='当前选中 :'+entity.id.id;
        }else{
            document.getElementById('result').innerHTML='当前选中 :';
        }
    },bmgl.ScreenSpaceEventType.LEFT_CLICK);
    var pinBuilder=new bmgl.PinBuilder();
    for (let i = 0; i <= 100; i++) {
        viewer.entities.add({
            id:(i+1),//设置一个id,方便进行点击判断
            position:bmgl.Cartesian3.fromDegrees(Math.random()*360-180,Math.random()*180-90),
            billboard:{
                image:pinBuilder.fromText((i+1),bmgl.Color.fromRandom(),50),
                heightReference:bmgl.HeightReference.CLAMP_TO_GROUND,
            },

        })
    }
</script>
</body>
</html>
                                                                                            
源码