123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>billboard应用</title>
- <link rel="stylesheet" href="../../dist/index.css" />
- <link href="../../cesium/Source/Widgets/widgets.css" rel="stylesheet">
- <script src="../../cesium/Build/Cesium/Cesium.js"></script>
- <script src="../../dist/index.js"></script>
- <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
- <style>
- * {
- padding: 0;
- margin: 0;
- }
- </style>
- </head>
- <body>
- <div style="display: flex;">
- <div id="info" style="height: 100vh; width: 30vw;">
- <ul>
- <li>
- <span>scale</span>
- <span style="margin-left: 2em;">
- 0倍
- <input type="range" min="0" max="10" value="1" step="0.01" onchange="changescale(this.value)">
- 10倍
- </span><br>
- </li>
- <li>
- <span>pixelOffset_x</span>
- <span style="margin-left: 2em;">
- -50
- <input type="range" min="-50" max="50" value="0" step="1" onchange="changepixelOffset_x(this.value)">
- 50
- </span><br>
- </li>
- <li>
- <span>pixelOffset_y</span>
- <span style="margin-left: 2em;">
- -50
- <input type="range" min="-50" max="50" value="0" step="1" onchange="changepixelOffset_y(this.value)">
- 50
- </span><br>
- </li>
- <li>
- <span>eyeOffset_x</span>
- <span style="margin-left: 2em;">
- -50
- <input type="range" min="-50" max="50" value="0" step="1" onchange="changeeyeOffset_x(this.value)">
- 50
- </span><br>
- </li>
- <li>
- <span>eyeOffset_y</span>
- <span style="margin-left: 2em;">
- -50
- <input type="range" min="-50" max="50" value="0" step="1" onchange="changeeyeOffset_y(this.value)">
- 50
- </span><br>
- </li>
- <li>
- <span>eyeOffset_z</span>
- <span style="margin-left: 2em;">
- -50
- <input type="range" min="-50" max="50" value="0" step="1" onchange="changeeyeOffset_z(this.value)">
- 50
- </span><br>
- </li>
- <li>
- <select name="selectList" onchange="changehorizontalOrigin(this.value)">
- <option value="0">CENTER</option>
- <option value="1">LEFT</option>
- <option value="2">RIGHT</option>
- </select>
- </li>
- <li>
- <select name="selectList" onchange="changeverticalOrigin(this.value)">
- <option value="0">CENTER</option>
- <option value="1">BOTTOM</option>
- <option value="2">BASELINE</option>
- <option value="3">TOP</option>
- </select>
- </li>
- <li>
- <span>rotation</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="360" value="0" step="1" onchange="changerotation(this.value)">
- 360
- </span><br>
- </li>
- <li>
- <span>alignedAxis_x</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="1" value="0" step="0.01" onchange="changealignedAxis_x(this.value)">
- 1
- </span><br>
- </li>
- <li>
- <span>alignedAxis_y</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="1" value="0" step="0.01" onchange="changealignedAxis_y(this.value)">
- 1
- </span><br>
- </li>
- <li>
- <span>alignedAxis_z</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="1" value="0" step="0.01" onchange="changealignedAxis_z(this.value)">
- 1
- </span><br>
- </li>
- <li>
- <span>width</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="1000" value="0" step="1" onchange="changewidth(this.value)">
- 1000
- </span><br>
- </li>
- <li>
- <span>height</span>
- <span style="margin-left: 2em;">
- 0
- <input type="range" min="0" max="1000" value="0" step="1" onchange="changeheight(this.value)">
- 1000
- </span><br>
- </li>
- </ul>
- </div>
- <div id="map" style="height: 100vh; width: 70vw;"></div>
- </div>
- </body>
- <script>
- window.CESIUM_BASE_URL = '../../cesium/Build/CesiumUnminified';
- Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI2MjIyODA4ZS0zNmRmLTQwNGMtYjZkNC0wOGY2NDdmODgyZTUiLCJpZCI6ODMyOCwiaWF0IjoxNjA2MjkyNDE1fQ.ZhhxNIJ-TzstpcavQBNL7xRwytBat3G2__3jr7lJ8yg'
- var viewer = CTMapOl.thrdime.viewercontrol.globalviewer('map', CTMapOl.thrdime.viewercontrol.globalvieweroptions())
- viewer._cesiumWidget._creditContainer.style.display = 'none'
- CTMapOl.thrdime.imagerylayercontrol.removeAll(viewer, true)
- CTMapOl.thrdime.imagerylayercontrol.addImageryProvider(viewer, CTMapOl.thrdime.imagerylayercontrol.gettdtImagery('img', "img_w"))
- CTMapOl.thrdime.imagerylayercontrol.addImageryProvider(viewer, CTMapOl.thrdime.imagerylayercontrol.gettdtImagery('cia', "cia_w"))
- CTMapOl.thrdime.cameracontrol.setDEFAULT_VIEW_RECTANGLE(116.38, 39.90, 116.40, 39.92)
- CTMapOl.thrdime.cameracontrol.setcamera(viewer, CTMapOl.thrdime.cameracontrol.getcameraoptionswithdetile(116.38, 39.90, 5000, 0, -90, 0))
- CTMapOl.thrdime.viewercontrol.addterrainct(viewer)
- let scale = 1
- function changescale(value) {
- scale = value
- }
- let pixelOffset_x = 0
- let pixelOffset_y = 0
- function changepixelOffset_x(value) {
- pixelOffset_x = value
- }
- function changepixelOffset_y(value) {
- pixelOffset_y = value
- }
- let eyeOffset_x = 0
- let eyeOffset_y = 0
- let eyeOffset_Z = 0
- function changeeyeOffset_x(value) {
- eyeOffset_x = value
- }
- function changeeyeOffset_y(value) {
- eyeOffset_y = value
- }
- function changeeyeOffset_z(value) {
- eyeOffset_z = value
- }
- let horizontalOrigin = Cesium.HorizontalOrigin.CENTER
- function changehorizontalOrigin(value) {
- switch (value) {
- case '0':
- horizontalOrigin = Cesium.HorizontalOrigin.CENTER
- break
- case '1':
- horizontalOrigin = Cesium.HorizontalOrigin.LEFT
- break
- case '2':
- horizontalOrigin = Cesium.HorizontalOrigin.RIGHT
- break
- }
- }
- let verticalOrigin = Cesium.VerticalOrigin.CENTER
- function changeverticalOrigin(value) {
- switch (value) {
- case '0':
- verticalOrigin = Cesium.VerticalOrigin.CENTER
- break
- case '1':
- verticalOrigin = Cesium.VerticalOrigin.BOTTOM
- break
- case '2':
- verticalOrigin = Cesium.VerticalOrigin.BASELINE
- break
- case '3':
- verticalOrigin = Cesium.VerticalOrigin.TOP
- break
- }
- }
- let rotation = 0
- function changerotation(value) {
- rotation = value / 180 * Math.PI
- }
- let alignedAxis_x = 0
- let alignedAxis_y = 0
- let alignedAxis_z = 0
- function changealignedAxis_x(value) {
- alignedAxis_x = value
- }
- function changealignedAxis_y(value) {
- alignedAxis_y = value
- }
- function changealignedAxis_z(value) {
- alignedAxis_Z = value
- }
- let width = 100
- function changewidth(value) {
- width = value
- }
- let height = 100
- function changeheight(value) {
- height = value
- }
- let Cartographicpos = Cesium.Cartographic.fromDegrees(116.38, 39.90, 0)
- let pos = Cesium.Cartographic.toCartesian(Cartographicpos)
- this.setTimeout(() => {
- var promise = Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, [Cartographicpos]);
- promise.then(res => {
- console.log(res)
- pos = Cesium.Cartographic.toCartesian(res[0])
- console.log(pos)
- })
- }, 1000)
- viewer.entities.add({
- position: new Cesium.CallbackProperty(() => {
- return pos
- }),
- billboard: {
- image: "../assets/monitor-online.png", // default: undefined
- show: true, // default
- scale: new Cesium.CallbackProperty(() => {
- return Number(scale)
- }),
- pixelOffset: new Cesium.CallbackProperty(() => {
- return new Cesium.Cartesian2(Number(pixelOffset_x), Number(pixelOffset_y))
- }),
- eyeOffset: new Cesium.CallbackProperty(() => {
- return new Cesium.Cartesian3(Number(eyeOffset_x), Number(eyeOffset_y), Number(eyeOffset_Z))
- }),
- horizontalOrigin: new Cesium.CallbackProperty(() => {
- return horizontalOrigin
- }),
- verticalOrigin: new Cesium.CallbackProperty(() => {
- return verticalOrigin
- }),
- rotation: new Cesium.CallbackProperty(() => {
- return rotation
- }),
- alignedAxis: new Cesium.CallbackProperty(() => {
- return new Cesium.Cartesian3(Number(alignedAxis_x), Number(alignedAxis_y), Number(alignedAxis_z))
- }),
- width: new Cesium.CallbackProperty(() => {
- return width
- }),
- height: new Cesium.CallbackProperty(() => {
- return height
- }),
- },
- });
- </script>
- </html>
|