显示源代码
Primitive加载贴地billboard
 开发文档
            <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <script src="http://bigemap.com/offline_data/newjunbiao/vue.js"></script>
        <link
            href="http://ua.bigemap.com:30081/bmsdk/bigemap-gl.js/v1.1.0/Widgets/widgets.css"
            rel="stylesheet"
        />
        <script src="http://ua.bigemap.com:30081/bmsdk/bigemap-gl.js/v1.1.0/bigemap-gl.js"></script>
        <!-- elementui -->
        <script src="http://bigemap.com/offline_data/newjunbiao/elementui.js"></script>
        <link
            rel="stylesheet"
            href="http://bigemap.com/offline_data/newjunbiao/elementui.css"
        />
        <title>Primitive加载贴地billboard</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            html,
            body {
                width: 100%;
                height: 100%;
            }
            #app {
                width: 100%;
                height: 100%;
            }
            #baseMap {
                width: 100%;
                height: 100%;
            }
            .tools {
                position: absolute;
                z-index: 9;
                top: 40px;
                right: 60px;
                width: 200px;
                height: 40px;
                display: flex;
                align-items: center;
            }
        </style>
    </head>
    <body>
        <div id="app">
            <div id="baseMap"></div>
        </div>
        <script>
            window.viewer = null;
            window.onload = () => {
                new Vue({
                    el: "#app",
                    data() {
                        return {};
                    },
                    mounted() {
                        this.initMap();
                    },
                    methods: {
                        //初始化地图
                        initMap() {
                            bmgl.Config.HTTP_URL =
                                "http://ua.bigemap.com:30081/bmsdk/";
                            viewer = new bmgl.Viewer("baseMap", {
                                mapId: "bigemap.dc-tian-w-satellite",
                                infoBox: false,
                                selectionIndicator: false,
                                requestRenderMode: false,
                                terrainId: "bigemap.dc-terrain",
                            });
                            //开启地形检测
                            viewer.scene.globe.depthTestAgainstTerrain = true;
                            this.initMarkers(viewer);
                            // console.log(bmgl,"bmgl");
                        },
                        // 加载billboard点位
                        initMarkers(viewer) {
                            viewer.camera.setView({
                                destination: bmgl.Cartesian3.fromDegrees(
                                    104.4335533,
                                    31.1592181,
                                    8000
                                ),
                            });
                            const billboardCollection = new bmgl.BillboardCollection({
                                    scene: viewer.scene,
                                });
                            viewer.scene.primitives.add(billboardCollection);
                            viewer.scene.globe.depthTestAgainstTerrain = true;
                            fetch("/offline_data/3000.geojson")
                                .then((r) => r.json())
                                .then((data) => {
                                    console.log(data);
                                    data.features.forEach((p) => {
                                        // 先将经纬度转换为世界坐标
                                        const position =
                                            bmgl.Cartesian3.fromDegrees(
                                                p.geometry.coordinates[0],
                                                p.geometry.coordinates[1]
                                            );
                                        // 添加图标
                                        billboardCollection.add({
                                            position: position,
                                            image: "/offline_data/point.png",
                                            verticalOrigin:
                                                bmgl.VerticalOrigin.BOTTOM,
                                            width: 32,
                                            height: 32,
                                            heightReference:
                                                bmgl.HeightReference
                                                    .CLAMP_TO_GROUND, // 贴地
                                        });
                                    });
                                    viewer.scene.requestRender();
                                });
                        },
                    },
                    beforeDestroy() {
                        viewer.destroy();
                        viewer = null;
                    },
                });
            };
        </script>
    </body>
</html>