WMTS
| let tdtIMGLabel = new Cesium.WebMapTileServiceImageryProvider({ |
| |
| url: "http://t{s}.tianditu.gov.cn/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&tk=" + tdtKey, |
| subdomains: subdomains, |
| layer: "tdtCiaLayer", |
| style: "default", |
| format: "image/png", |
| tileMatrixSetID: "GoogleMapsCompatible", |
| show: true, |
| TRANSPARENT: true, |
| }); |
WMS
| var district = new this.Cesium.WebMapServiceImageryProvider({ |
| url: geoserverUrl+"geoserver/cesium/wms", |
| layers: "cesium:province,cesium:china", |
| parameters: { |
| FORMAT: "image/png", |
| VERSION: "1.1.1", |
| SERVICE: "WMS", |
| TRANSPARENT: true, |
| }, |
| srs: "EPSG:4326", |
| |
| }); |
| viewer.imageryLayers.addImageryProvider(district); |
GeoJSON
| |
| yfcDataSource = Cesium.GeoJsonDataSource.load( |
| "../data/geojson/yangfangcun_h.geojson", { |
| clampToGround: false, |
| stroke: Cesium.Color.RED, |
| fill: Cesium.Color.TRANSPARENT, |
| strokeWidth: 3, |
| markerSymbol: '?', |
| zIndex: 3 |
| }) |
| yfcDataSource.then(function (data) { |
| |
| viewer.dataSources.add(yfcDataSource); |
| entities =dataSource.entities.values; |
| for (var i = 0; i < entities.length;i++) { |
| var entity = entities[i]; |
| |
| var color=Cesium.Color.fromRandom({alpha: 0.7}); |
| entity.polygon.fill = true; |
| entity.polygon.material = color; |
| entity.polygon.outline = true; |
| entity.polygon.outlineColor = Cesium.Color.YELLOW; |
| } |
| |
| }); |
| |
| |
| var urlpath = "../data/json/world.json" |
| $.get(urlpath, function (data) { |
| const josnN = JSON.parse(data); |
| const features = josnN.features; |
| addDataToGlobe(features); |
| }) |
| function addDataToGlobe(features){ |
| const instances = []; |
| for(let i=0; i<features.length; i++){ |
| for(let j=0; j<features[i].geometry.coordinates.length; j++){ |
| const polygonArr = features[i].geometry.coordinates[j].toString().split(','); |
| const polygon = new Cesium.PolygonGeometry({ |
| polygonHierarchy : new Cesium.PolygonHierarchy( |
| Cesium.Cartesian3.fromDegreesArray(polygonArr) |
| ), |
| vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT |
| }); |
| const geometry = Cesium.PolygonGeometry.createGeometry(polygon); |
| instances.push(new Cesium.GeometryInstance({ |
| geometry : geometry, |
| attributes : { |
| color : Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.fromRandom({alpha : 0.7})), |
| }, |
| })); |
| } |
| } |
| |
| const primitive = new Cesium.Primitive({ |
| geometryInstances : instances, |
| appearance : new Cesium.PerInstanceColorAppearance({ |
| translucent : true, |
| closed : false |
| }), |
| }); |
| |
| scene.primitives.add(primitive); |
| } |
3DTileset
| tileset = new Cesium.Cesium3DTileset({ |
| url: "../data/3dtiles/yangfangcun/tileset.json", |
| |
| }); |
| |
| tileset.readyPromise |
| .then(function (tileset) { |
| viewer.scene.primitives.add(tileset); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| var cartographic = Cesium.Cartographic.fromCartesian( |
| tileset.boundingSphere.center |
| ); |
| var surface = Cesium.Cartesian3.fromRadians( |
| cartographic.longitude, |
| cartographic.latitude, |
| 0.0 |
| ); |
| var offset = Cesium.Cartesian3.fromRadians( |
| cartographic.longitude, |
| cartographic.latitude, |
| cartographic.height |
| |
| ); |
| var translation = Cesium.Cartesian3.subtract( |
| offset, |
| surface, |
| new Cesium.Cartesian3() |
| ); |
| tileset.modelMatrix = Cesium.Matrix4.fromTranslation(translation); |
| zoomTo('vallige') |
| |
| }) |
| .otherwise(function (error) { |
| console.log(error); |
| }); |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· spring官宣接入deepseek,真的太香了~