首页 / 浏览问题 / 三维GIS / 问题详情
自己加的功能按钮没效果
cai
7EXP 2020年08月10日

我想在image这个框内 加一个按钮(如图所示)

实现收起的功能  但并不起作用。而且这个按钮的div一定要写在这个框所在的div里才会显示

否则 运行后看不见    不知道为什么   还请大佬指导指导

代码

<div id="toolbar" class="param-container tool-bar">
			<div class="buttonblack">	
			<span type="button" id="play" class="button black" title="开始"></span>
			<span type="button" id="pause" class="button black" title="暂停"></span>
			<span type="button" id="stop" class="button black" title="停止"></span>
		
			</div>
			<div style="width: 150px;">
				<select id="stopList" class="form-control" style="width: 100%;">
				</select>
			</div>
			<div class="checkbox">
				<label>
					<input type="checkbox" id="show-line" checked> 显示飞行路线
				</label>
			</div>
			<div class="checkbox">
				<label>
					<input type="checkbox" id="show-stop" checked> 显示飞行站点
				</label>
			</div>
		
		<div class="spana">
			<span type="button" class="spanb">收起</span>
		</div>	
		</div> 
<script type="text/javascript">
var flyManager;
		  function onload(Cesium) {
			var toolbar =document.getElementById('toolbar');
			var viewer = new Cesium.Viewer('cesiumContainer');
			var routes = new Cesium.RouteCollection(viewer.entities);
			var scene = viewer.scene;
			var camera =viewer.camera;
var promise = scene.open("http://localhost:8090/iserver/services/3D-CBD-2/rest/realspace");
		      promise.then(function (layers) {
				  camera.setView({
				      destination: Cesium.Cartesian3.fromDegrees(116.4581, 39.9122, 2000)
					  });
			  });
		       scene.globe.depthTestAgainstTerrain = false;
			    //添加fpf飞行文件,fpf由SuperMap iDesktop生成
			   var fpfUrl='./fpf/飞行.fpf';
			   routes.fromFile(fpfUrl);
			    //初始化飞行管理
			    var flyManager = new Cesium.FlyManager({
				   scene: scene,
				   routes: routes
			    });
			  //注册站点到达事件
			    flyManager.stopArrived.addEventListener(function (routeStop) {
				routeStop.waitTime = 0.6; // 在每个站点处停留1.5s
			     });

			    flyManager.readyPromise.then(function (){ // 飞行路线就绪
				    var currentRoute = flyManager.currentRoute;
				    currentRoute.isLineVisible = true;
				    currentRoute.isStopVisible = true;
				     //生成飞行文件中的所有站点列表
				    var allStops = flyManager.getAllRouteStops();
				    var menu = document.getElementById('stopList');
				   for (var i = 0, j = allStops.length; i < j; i++) {
					var option = document.createElement('option');
					option.innerHTML = "站点 " + (i + 1);
					option.value = allStops[i].index;
					menu.appendChild(option);
				    }

				$('#stopList').change(function () { //注册站点切换事件
					flyManager && flyManager.stop();
					var index = parseInt($(this).val()); // 站点的索引
					var route = flyManager.currentRoute;
					var stop = route.get(index);
					flyManager.currentStopIndex = index;
					flyManager.viewToStop(stop);
				});

				$('#play').click(function () {
					flyManager && flyManager.play();
				});
				$('#pause').click(function () {
					flyManager && flyManager.pause();
				});
				$('#stop').click(function () {
					flyManager && flyManager.stop();
				});

				$('#show-line').change(function(){
					currentRoute.isLineVisible = $(this).prop('checked');
				});

				$('#show-stop').change(function(){
					currentRoute.isStopVisible = $(this).prop('checked');
				});

				$('#toolbar').show();
				$('#loadingbar').remove();
			 });
			 
		}
		//展开和收起
		$(document).ready(function(){
						 $('spanb').click(function(){
							 if($(this).text()=='展开')
							 {
								 $('#toolbox').show();
								 $(this).text('收起');
							 }
							 else
							 {
								 $('#toolbox').hide();
								 $(this).text('展开');
							 }
						 });
		});

问题关闭原因: 搞错了
...