<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>卫星扫描</title> <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> </head> <style> body { margin: 0; padding: 0; } #container { position: absolute; top: 0; bottom: 0; width: 100%; } .bmgl-widget-credits { display: none } </style> <body> <div id='container'></div> </body> <script> bmgl.Config.HTTP_URL = 'http://bigemap.com:9000'; var viewer = new bmgl.Viewer('container', { mapId: 'bigemap.zhongkexingtu', requestRenderMode: false, timeline: true, shouldAnimate: true, mapId: 'bigemap.zhongkexingtu', }); var data = []; data = [{ longitude: 116.405419, dimension: 39.918034, height: 700000, time: 0 }, { longitude: 115.2821, dimension: 39.918145, height: 700000, time: 40 }, { longitude: 114.497402, dimension: 39.344641, height: 700000, time: 100 }, { longitude: 107.942392, dimension: 35.559967, height: 700000, time: 280 }, { longitude: 106.549265, dimension: 34.559967, height: 700000, time: 360 }, { longitude: 95.2821, dimension: 32.918145, height: 700000, time: 400 }, { longitude: 94.497402, dimension: 30.344641, height: 700000, time: 450 }, { longitude: 87.942392, dimension: 25.559967, height: 700000, time: 550 }, { longitude: 66.549265, dimension: 24.559967, height: 700000, time: 600 }]; // 起始时间 var start = bmgl.JulianDate.fromDate(new Date(2017, 7, 11)); // 结束时间 var stop = bmgl.JulianDate.addSeconds(start, 600, new bmgl.JulianDate()); // 设置始时钟始时间 viewer.clock.startTime = start.clone(); // 设置时钟当前时间 viewer.clock.currentTime = start.clone(); // 设置始终停止时间 viewer.clock.stopTime = stop.clone(); // 时间速率,数字越大时间过的越快 viewer.clock.multiplier = 10; // 时间轴 viewer.timeline.zoomTo(start, stop); // 循环执行 viewer.clock.clockRange = bmgl.ClockRange.LOOP_STOP; var property = computeFlight(data); // 添加模型 var planeModel = viewer.entities.add({ // 和时间轴关联 availability: new bmgl.TimeIntervalCollection([new bmgl.TimeInterval({ start: start, stop: stop })]), position: property, // 根据所提供的速度计算点 orientation: new bmgl.VelocityOrientationProperty(property), // 模型数据 model: { uri: '/SampleData/models/CesiumAir/Cesium_Air.glb', minimumPixelSize: 128 }, path: { resolution: 1, material: new bmgl.PolylineGlowMaterialProperty({ glowPower: .1, color: bmgl.Color.YELLOW }), width: 10 } }); planeModel.position.setInterpolationOptions({ //设定位置的插值算法 interpolationDegree: 5, interpolationAlgorithm: bmgl.LagrangePolynomialApproximation }); //绘制透明圆锥体 var property2 = computeFlight2(data); var entity_ty = viewer.entities.add({ availability: new bmgl.TimeIntervalCollection([new bmgl.TimeInterval({ start: start, stop: stop })]), position: property2, orientation: new bmgl.VelocityOrientationProperty(property2), cylinder: { HeightReference: bmgl.HeightReference.CLAMP_TO_GROUND, length: 700000, topRadius: 0, bottomRadius: 700000 / 2, material: bmgl.Color.RED.withAlpha(.4), outline: !0, numberOfVerticalLines: 0, outlineColor: bmgl.Color.BLUE.withAlpha(.8) }, }); entity_ty.position.setInterpolationOptions({ interpolationDegree: 5, interpolationAlgorithm: bmgl.LagrangePolynomialApproximation }); function computeFlight(source) { var property = new bmgl.SampledPositionProperty(); for (var i = 0; i < source.length; i++) { var time = bmgl.JulianDate.addSeconds(start, source[i].time, new bmgl.JulianDate); var position = bmgl.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height); // 添加位置,和时间对应 property.addSample(time, position); } return property; } function computeFlight2(source) { var property = new bmgl.SampledPositionProperty(); for (var i = 0; i < source.length; i++) { var time = bmgl.JulianDate.addSeconds(start, source[i].time, new bmgl.JulianDate); var position = bmgl.Cartesian3.fromDegrees(source[i].longitude, source[i].dimension, source[i].height / 2); // 添加位置,和时间对应 property.addSample(time, position); } return property; } viewer.camera.setView({ destination: bmgl.Cartesian3.fromDegrees(100.405419, 20.918034, 3100000.0), orientation: { heading: bmgl.Math.toRadians(30.0), pitch: bmgl.Math.toRadians(-50.0), roll: 0.0 } }); </script> </html>
源码