2. Map creation
Cesium calls its map a Viewer. Its imagery and terrain come from Cesium ion, so it needs an access token. The viewer ships with its own controls — home, scene mode (3D / 2D / Columbus view), base layer picker, navigation help, timeline — and they are all on by default:
Cesium.Ion.defaultAccessToken = 'YOUR_CESIUM_ION_ACCESS_TOKEN';
const viewer = new Cesium.Viewer('map', {
terrain: Cesium.Terrain.fromWorldTerrain(),
infoBox: false,
selectionIndicator: false,
geocoder: false
});
viewer.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(132.4553, 34.28, 25000),
orientation: {
heading: 0,
pitch: Cesium.Math.toRadians(-50),
roll: 0
}
});
About the token in this live editor
The example below expects a token to be baked in when this site is built (locally: set CESIUM_ION_ACCESS_TOKEN in .env and run uv run python scripts/generate_keys.py; on Cloudflare Pages it comes from a build environment variable). If no token was provided, the preview shows a notice instead of a globe. A free ion account gives you a default token — create one here.
Camera height, not zoom level
Cesium has no zoom level. The camera is positioned in 3D space, so Cartesian3.fromDegrees(lng, lat, height) takes a height in metres — here 25 km, south of the city — and orientation.pitch tilts the view down 50° so the terrain is visible. Coordinate order is [lng, lat] — the same as MapLibre, unlike Leaflet.
Which widgets are switched off
Only three, and each for a reason: infoBox and selectionIndicator both react to clicking a feature, which fights with drawing, and the geocoder needs a token with the geocode scope. Everything else is Cesium's default set — try the scene mode picker to draw in 2D and 3D with the same code.