Appearance
KBE3D / KBCore / Cesium / createOsmBuildingsAsync
函数: createOsmBuildingsAsync()
createOsmBuildingsAsync(
options?: {defaultColor?:Color;style?:Cesium3DTileStyle;enableShowOutline?:boolean;showOutline?:boolean; }):Promise<Cesium3DTileset>
Creates a Cesium3DTileset instance for the Cesium OSM Buildings tileset.
参数
options?
Construction options. Any options allowed by the Cesium3DTileset constructor may be specified here. In addition to those, the following properties are supported:
defaultColor?
The default color to use for buildings that do not have a color. This parameter is ignored if <code>options.style</code> is specified.
style?
The style to use with the tileset. If not specified, a default style is used which gives each building or building part a color inferred from its OpenStreetMap <code>tags</code>. If no color can be inferred, <code>options.defaultColor</code> is used.
enableShowOutline?
boolean
If true, enable rendering outlines. This can be set to false to avoid the additional processing of geometry at load time.
showOutline?
boolean
Whether to show outlines around buildings. When true, outlines are displayed. When false, outlines are not displayed.
返回
Promise<Cesium3DTileset>
Examples
ts
// Create Cesium OSM Buildings with default styling
const viewer = new Cesium.Viewer("cesiumContainer");
try {
const tileset = await Cesium.createOsmBuildingsAsync();
viewer.scene.primitives.add(tileset));
} catch (error) {
console.log(`Error creating tileset: ${error}`);
}ts
// Create Cesium OSM Buildings with a custom style highlighting
// schools and hospitals.
const viewer = new Cesium.Viewer("cesiumContainer");
try {
const tileset = await Cesium.createOsmBuildingsAsync({
style: new Cesium.Cesium3DTileStyle({
color: {
conditions: [
["${feature['building']} === 'hospital'", "color('#0000FF')"],
["${feature['building']} === 'school'", "color('#00FF00')"],
[true, "color('#ffffff')"]
]
}
})
});
viewer.scene.primitives.add(tileset));
} catch (error) {
console.log(`Error creating tileset: ${error}`);
}