申请成为天地图开发者,创建应用
编写代码:
<!DOCTYPE html> <html lang="en"> <head> <!-- Use correct character set. --> <meta charset="utf-8" /> <!-- Tell IE to use the latest, best version. --> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Make the application on mobile take up the full browser screen and disable user scaling. --> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" /> <title>Hello World!</title> <script src="../Build/CesiumUnminified/Cesium.js"></script> <style> @import url(../Build/CesiumUnminified/Widgets/widgets.css); html, body, #cesiumContainer { width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden; } </style> </head> <body> <div id="cesiumContainer"></div> <script> const viewer = new Cesium.Viewer('cesiumContainer', { timeline:false, animation:false, vrButton:true, sceneModePicker:false, infoBox:true, scene3DOnly:true, imageryProvider: new Cesium.WebMapTileServiceImageryProvider({ url: "http://t0.tianditu.gov.cn/vec_w/wmts?tk=你的token" , layer: "vec", style: "default", tileMatrixSetID: "w", format: "tiles", maximumLevel: 18, }), }) if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) { //判断是否支持图像渲染像素化处理 viewer.resolutionScale = window.devicePixelRatio } viewer.scene.postProcessStages.fxaa.enabled = true // 暗色系 // viewer.imageryLayers.get(0).hue = 3 // viewer.imageryLayers.get(0).contrast = -1.2 viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({ url: "http://t{s}.tianditu.gov.cn/ibo_w/wmts?tk=你的token" , layer: "ibo", style: "default", tileMatrixSetID: "w", format: "tiles", maximumLevel: 18, subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'] })) viewer.imageryLayers.addImageryProvider(new Cesium.WebMapTileServiceImageryProvider({ url: "http://t0.tianditu.gov.cn/cva_w/wmts?tk=你的token" , layer: "cva", style: "default", tileMatrixSetID: "w", format: "tiles", maximumLevel: 18 })) viewer._cesiumWidget._creditContainer.style.display = "none"; var tileset = new Cesium.Cesium3DTileset({ url: "../Scene/tileset.json", maximumScreenSpaceError : 1}); viewer.scene.primitives.add(tileset); viewer.zoomTo(tileset); viewer.homeButton.viewModel.command.beforeExecute.addEventListener(function(commandInfo) { // Fly to tileset viewer.flyTo(tileset); // Tell the home button not to do anything commandInfo.cancel = true; }); </script> </body> </html>
效果:
标签:tileset,viewer,笔记,url,Cesium,new,true,加载 From: https://www.cnblogs.com/yhlx125/p/17538960.html