<!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> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> <style> body { margin: 0; padding: 0; } #container { position: absolute; top: 0; bottom: 0; width: 100%; } #add{ position: absolute; left: 25px; top:20px; color: #333; background-color: #f1f1f1; padding: 15px; } #add a{ display: inline-block; padding: 5px 10px; } .bmgl-widget-credits{display:none} </style> <title>part_test</title> </head> <body> <div id='container'></div> <div id="add"> <a href="javascript:void(0);" id="start" data-type="start">开始</a> <a href="javascript:void(0);" data-type="stop">停止</a> </div> <script> bmgl.Config.HTTP_URL = 'http://bigemap.com:9000'; var viewer = new bmgl.Viewer('container', { terrainId: 'bigemap.9af15d8e', mapId: 'bigemap.zhongkexingtu', requestRenderMode:false, }); //启用地形遮挡 viewer.scene.globe.depthTestAgainstTerrain=true; viewer.camera.setView({ destination:bmgl.Cartesian3.fromDegrees(103.62908521232548,30.925160500796443,9271.09381883), orientation:{"heading":6.282927573132531,"roll":6.283184223254143,"pitch":-0.7898537685249098} }); var height=650; var entity=viewer.entities.add({ show:false, polygon:{ extrudedHeight:new bmgl.CallbackProperty(function (e) { if (type==='run'){ height=height<2000?height+=0.25:2000; } return height; },false), hierarchy:bmgl.Cartesian3.fromDegreesArray([103.67642392404379,30.979978615804974,103.64449597662316,30.950517790429306,103.59338702866808,30.940714212782957,103.53219402255492,30.961381555053634,103.51394213503228,31.000584107166144,103.50470567587763,31.035048201444695,103.54711355874316,31.05039059266936,103.64366019610316,31.063488152089803,103.70637133251877,31.06890226409121,103.73128368984909,31.047311092748085,103.71700788382444,31.012171641339606,103.70410968549551,30.981436193269417,103.67715457454325,30.980169097270256]), material:bmgl.Color.fromAlpha(bmgl.Color.BLUE,0.5) } }); var type=''; document.getElementById('add').addEventListener('click',function (e) { var dataset= e.target.dataset; switch (dataset.type) { case 'stop': type=''; document.getElementById('start').innerHTML='开始'; height=650; entity.show=false; break; case 'start': entity.show=true; viewer.camera.setView({ destination:bmgl.Cartesian3.fromDegrees(103.62908521232548,30.925160500796443,9271.09381883), orientation:{"heading":6.282927573132531,"roll":6.283184223254143,"pitch":-0.7898537685249098} }); if (type){ type=''; e.target.innerHTML='继续'; }else{ type='run'; e.target.innerHTML='暂停'; } break; } }); </script> </body> </html>
源码