Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cesium OSM Building Styling Issue #477

Closed
oshopgiri opened this issue Feb 17, 2021 · 3 comments
Closed

Cesium OSM Building Styling Issue #477

oshopgiri opened this issue Feb 17, 2021 · 3 comments
Labels

Comments

@oshopgiri
Copy link

I am trying to style Cesium OSM Buildings using Resium's Cesium3DTileset and style attribute. Below is the component:

import * as React from 'react'
import {CameraFlyTo, Cesium3DTileset, Primitive, Viewer} from 'resium'
import {Cartesian3, Cesium3DTileStyle, createOsmBuildings, createWorldTerrain, Ion, IonResource, Math} from 'cesium'

interface BuildingsProps {
}

interface BuildingsState {
	style: Cesium3DTileStyle
}

export default class Buildings extends React.Component<BuildingsProps, BuildingsState> {
	constructor(props: BuildingsProps) {
		super(props)

		this.state = {
			style: new Cesium3DTileStyle({
				color: {
					conditions: [
						[
							"${feature['building']} === 'apartments' || ${feature['building']} === 'residential'",
							"color('cyan', 0.9)",
						],
						[true, "color('white')"],
					],
				},
			})
		}
	}

	render() {
		return (
			<Viewer
				animation={false}
				full
				terrainProvider={createWorldTerrain()}
				useBrowserRecommendedResolution={true}
			>
				<CameraFlyTo
					cancelFlightOnUnmount
					destination={Cartesian3.fromDegrees(-122.3472, 47.598, 370)}
					once
					orientation={
						{
							heading: Math.toRadians(10),
							pitch: Math.toRadians(-10)
						}
					}
				/>

				<Cesium3DTileset
					url={IonResource.fromAssetId(96188)}
					style={this.state.style}
				/>
			</Viewer>
		)
	}
}

The map view is rendering properly but the style is not. Can someone help me out with this?

@rot1024 rot1024 added the bug label Mar 5, 2021
@sanchitd5
Copy link

sanchitd5 commented Jul 6, 2021

This is a workaround I have found, and it works:

<Cesium3DTileset immediatelyLoadDesiredLevelOfDetail={true}
url={IonResource.fromAssetId(96188)}
onReady={(tileset) => {
var extras = tileset.asset.extras;
if (
defined(extras) &&
defined(extras.ion) &&
defined(extras.ion.defaultStyle)
) {
tileset.style = new Cesium3DTileStyle({
color: {
conditions: [
['${elementId} === 266548230',"color('red')"],
['${elementId} === 266547173',"color('red')"],
['${elementId} === 820382924',"color('green')"],
[true, 'color("white")']
]
}
});
}
}}
``
/>

@rot1024
Copy link
Member

rot1024 commented Sep 10, 2021

Resium v1.14 fixed this bug. Try it!

@rot1024 rot1024 closed this as completed Sep 10, 2021
@NoorAhmd
Copy link

Hi, In Resium how you managed to create createOsmBuildings()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants