<!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-satellite", infoBox: false, selectionIndicator: false, requestRenderMode: false, terrainId: "bigemap.dc-terrain", }); //開(kāi)啟地形檢測(cè) viewer.scene.globe.depthTestAgainstTerrain = true; this.initMarkers(viewer); // console.log(bmgl,"bmgl"); }, // 加載billboard點(diǎn)位 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) => { // 先將經(jīng)緯度轉(zhuǎn)換為世界坐標(biāo) const position = bmgl.Cartesian3.fromDegrees( p.geometry.coordinates[0], p.geometry.coordinates[1] ); // 添加圖標(biāo) 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>