<!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%; } #toolbar { position: absolute; top: 15px; left: 20px; z-index: 99; width: 150px; } #toolbar select { display: inline-block; position: relative; background: #303336; border: 1px solid #444; color: #edffff; fill: #edffff; border-radius: 4px; padding: 5px 12px; margin: 2px 3px; cursor: pointer; overflow: hidden; -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; } #toolDiv { left: 10px; top: 10px; margin-bottom: 10px; } .bmgl-widget-credits { display: none; } </style> <title>part_test</title> </head> <body> <div id="container"></div> <script> bmgl.Config.HTTP_URL = "http://bigemap.com:9000"; var viewer = new bmgl.Viewer("container", { mapId: "bigemap.zhongkexingtu", timeline: true, animation: true, }); var entity = undefined; viewer.scene.globe.enableLighting = true; viewer.scene.globe.depthTestAgainstTerrain = true; //运动的开始时间 var start = bmgl.JulianDate.fromDate(new Date()); //运动的结束时间 var stop = bmgl.JulianDate.addSeconds( start, 3600 * 24, new bmgl.JulianDate() ); //设置时间线的开始和结束时间 viewer.clock.startTime = start.clone(); viewer.clock.stopTime = stop.clone(); viewer.clock.currentTime = start.clone(); viewer.clock.clockRange = bmgl.ClockRange.LOOP_STOP; // 设置时钟的速率 viewer.clock.multiplier = 0.6; viewer.timeline.zoomTo(start, stop); var i = 0; function computeCirclularFlight(lon, lat, radius) { var property = new bmgl.SampledPositionProperty(); // 获取实时的经纬度位置 var times = setInterval(() => { i += 2.0; var radians = bmgl.Math.toRadians(i); var time = bmgl.JulianDate.addSeconds( start, i, new bmgl.JulianDate() ); var position = bmgl.Cartesian3.fromDegrees( lon + radius * 1.5 * Math.cos(radians), lat + radius * Math.sin(radians), 8750 ); property.addSample(time, position); if (i >= 360) clearInterval(times); // console.log("a"); }, 2000); // console.log("b"); return property; } //添加模型运动位置 var position = computeCirclularFlight(86.93047, 27.986914, 0.03); //创建的一个实体 entity = viewer.entities.add({ //模型运动起止时间 availability: new bmgl.TimeIntervalCollection([ new bmgl.TimeInterval({ start: start, stop: stop, }), ]), //模型的位置 position: position, //自动根据模型的位置计算模型的朝向. orientation: new bmgl.VelocityOrientationProperty(position), //加载模型的参数 model: { uri: "/SampleData/models/CesiumAir/Cesium_Air.glb", minimumPixelSize: 64, scale: 0.08, }, //展示模型的运动轨迹 path: { resolution: 1, material: new bmgl.PolylineGlowMaterialProperty({ glowPower: 0.1, color: bmgl.Color.YELLOW }), width: 10 } }); viewer.clock.shouldAnimate = true; viewer.trackedEntity = entity; </script> </body> </html>
源码