123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>三维-轨迹回放</title>
- <link rel="stylesheet" href="../../dist/index.css" />
- <script src="../../dist/index.js"></script>
- <link href="../../cesium/Source/Widgets/widgets.css" rel="stylesheet">
- <script src="../../cesium/Build/Cesium/Cesium.js"></script>
- </head>
- <body style="margin: 0; padding: 0;">
- <div id="map" style="height: 100vh; width: 100vw;"></div>
- <div class="input-card">
- <div class="input-item">
- <button id="doPlay">播放</button>
- <button id="pause">暂停</button>
- <button id="next">前进</button>
- <button id="prev">后退</button>
- <button id="show">显示</button>
- <button id="hide">隐藏</button>
- <button id="remove">删除</button>
- <button id="addPath">添加新路径</button>
- <p>
- <input id="range" type="range" min="0" max="1" style="width: 80%"
- step="0.001" value="0">
- </p>
- </div>
- </div>
- </body>
- <script>
- const viewer = new Cesium.Viewer("map", {
- // homeButton: false, // 是否显示首页按钮
- // geocoder: false, // 是否显示输入地名查找控件
- sceneModePicker: false, // 是否显示投影方式控件(包含二维及三维投影)
- // baseLayerPicker: false, // 是否显示帮助控件
- creditDisplay: false,
- // timeline: true,
- // infoBox: false, // 是否显示点击要素之后显示的信息
- selectionIndicator: false,
- imageryProvider: false,
- fullscreenButton: false
- })
- let pData = [
- [116.41136, 39.97569],
- [116.411794, 39.9068],
- [116.32969, 39.92940],
- [116.385438, 39.90610],
- ]
- let polyline = new CTMapOl.cesiumComponent.Polyline({
- path: pData,
- zoomto: true,
- strokeOpacity:0.8,
- });
- polyline.addTo({ viewer })
- var car = new CTMapOl.cesiumComponent.UVA(viewer, {
- btnBox: 150, // 左边按钮的盒子宽度
- bgColor: 'rgba(0,0,0,0.3)', // 控件的背景色
- width: 18, // 飞行器的宽度
- height: 27, // 飞行器的高度
- anchor: [9, 20], // 原点偏移
- path: pData, // 路径坐标;二维数组
- duration: 10000, // 播放时间
- onPlay: (info) => {
- let rangeV = document.getElementById('range')
- rangeV.value = info.progress
- }
- })
- car.addTo({ viewer });
- document.getElementById('doPlay').onclick = () => {
- car.play();
- }
- document.getElementById('pause').onclick = () => {
- car.pause();
- }
- document.getElementById('next').onclick = () => {
- car.fastFront();
- }
- document.getElementById('prev').onclick = () => {
- car.fastBack();
- }
- document.getElementById('hide').onclick = () => {
- car.hide();
- }
- document.getElementById('show').onclick = () => {
- car.show();
- }
- document.getElementById('remove').onclick = () => {
- car.remove();
- }
- document.getElementById('addPath').onclick = () => {
- let path = [
- [116.385438, 39.90610], // 上一个路径的终点
- [116.485438, 39.90610],
- ]
- let polyline = new CTMapOl.cesiumComponent.Polyline({
- path,
- strokeOpacity:0.8,
- strokeColor: 'red'
- })
- polyline.addTo({ viewer: map.Viewer })
- car.addPath({
- path: path.slice(1),
- distance: 0.02,
- duration: 1000, // 飞行时间
- })
- }
- document.getElementById('range').oninput = (e) => {
- car.moveTo(e.target.value)
- }
- </script>
- <style>
- /*地图*/
- .mapDIV {
- height: 100vh;
- width: 100vw;
- z-index: 1;
- }
- .add-switch {
- position: absolute;
- right: 30px;
- height: 68px;
- width: 30px;
- bottom: 112px;
- background: #FFFFFF 100%;
- color: #172537;
- border-radius: 4px;
- display: flex;
- flex-direction: column;
- align-items: center;
- z-index: 2;
- }
- .add-s-block {
- height: 20px;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- line-height: 20px;
- font-size: 12px;
- margin-bottom: 2px;
- color: #172537;
- }
- .add-zoom {
- width: 20px;
- height: 20px;
- background-image: url('../../dist/assets/image/ar/switch/add-zoom.svg');
- background-size: 100% 100%;
- cursor: pointer;
- }
- .sub-zoom {
- width: 20px;
- height: 20px;
- background-image: url('../../dist/assets/image/ar/switch/sub-zoom.svg');
- background-size: 100% 100%;
- cursor: pointer;
- }
- .add-zoom-out {
- width: 20px;
- height: 20px;
- background-image: url('../../dist/assets/image/ar/switch/add-zoom-out.svg');
- background-size: 100% 100%;
- }
- .sub-zoom-out {
- width: 20px;
- height: 20px;
- background-image: url('../../dist/assets/image/ar/switch/sub-zoom-out.svg');
- background-size: 100% 100%;
- }
- .add-s-block.btn-click {
- cursor: pointer;
- }
- .input-card {
- position: absolute;
- left: 15px;
- top: 15px;
- z-index: 999;
- }
- </style>
- </html>
|