<!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%; } .bmgl-widget-credits { display: none } </style> <title>Google Map Streets</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' }); //取消默认的点击事件 viewer.screenSpaceEventHandler.removeInputAction(bmgl.ScreenSpaceEventType.LEFT_CLICK); //禁止默认的地形遮挡 viewer.scene.globe.depthTestAgainstTerrain = false; var options = { lng: 117.1423291616, lat: 39.0645831633, height: 15.8, heading: 0.0, pitch: 0.0, roll: 0.0 }; var pinBuilder = new bmgl.PinBuilder(); viewer.entities.add({ id: 1,//设置一个id,方便进行点击判断 position: bmgl.Cartesian3.fromDegrees(options.lng, options.lat), billboard: { image: pinBuilder.fromText('自定义标题', bmgl.Color.RED, 50), heightReference: bmgl.HeightReference.CLAMP_TO_GROUND, }, }) var position = bmgl.Cartesian3.fromDegrees(options.lng, options.lat, options.height); // 相机看点的角度,如果大于0那么则是从地底往上看,所以要为负值,这里取-30度 var pitch = bmgl.Math.toRadians(-30); // 给定飞行一周所需时间,比如10s, 那么每秒转动度数 var angle = 360 / 30; // 给定相机距离点多少距离飞行,这里取值为5000m var distance = 5000; var startTime = bmgl.JulianDate.fromDate(new Date()); viewer.clock.startTime = startTime.clone(); // 开始时间 // viewer.clock.stopTime = stopTime.clone(); // 结速时间 viewer.clock.currentTime = startTime.clone(); // 当前时间 viewer.clock.clockRange = bmgl.ClockRange.CLAMPED; // 行为方式 viewer.clock.clockStep = bmgl.ClockStep.SYSTEM_CLOCK; // 时钟设置为当前系统时间; 忽略所有其他设置。 // 相机的当前heading var initialHeading = viewer.camera.heading; var Exection = function TimeExecution() { // 当前已经过去的时间,单位s var delTime = bmgl.JulianDate.secondsDifference(viewer.clock.currentTime, viewer.clock.startTime); var heading = bmgl.Math.toRadians(delTime * angle) + initialHeading; viewer.scene.camera.setView({ destination: position, // 点的坐标 orientation: { heading: heading, pitch: pitch, } }); viewer.scene.camera.moveBackward(distance); }; viewer.clock.onTick.addEventListener(Exection); </script> </body> </html>
源码