JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://nextspace-limited.github.io/nextspace-web-bundle/dist/nextspace.js?v1"></script>
<div id="VIEWER">
<div id="MSG">
</div>
</div>
CSS
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#VIEWER {
width: 100%;
height: 100%;
}
#MSG {
position: absolute;
z-index: 1;
top: 100px;
left: 100px;
color: white;
padding: 8px;
border-radius: 6px;
background: black;
}
#MSG >button {
font-size: 15px;
}
JavaScript
BModels.ENVIRONMENT.Reset({
// Replace with your account ID.
accountId: "examples",
// Replace with UAT when used for real work.
env: BModels.Api.EEnv.DEV,
sessionId: "anonymous"
});
const init = async () => {
// Proxy Cesium Ion requests through the Nextspace API.
// This allows for access to Cesium Ion resources without exposing your token, or the default token.
const api = BModels.ENVIRONMENT.Api().GetBruceApi({});
await api.Loading;
Cesium.Ion.defaultServer = api.GetBaseUrl() + "proxy/cesium-ion/";
Cesium.Ion.defaultAccessToken = "proxy";
const viewer = new Cesium.Viewer("VIEWER", {
// Excluding the default imagery and terrain providers.
// This is to avoid consuming Cesium Ion or Bing Maps quota before custom tiles load.
imageryProvider: false,
baseLayerPicker: false,
terrainProvider: null
});
// Rendering some defaults that work well without requiring a Cesium token.
await BEngine.TileRenderEngine.Map.Navigator.Render({
tiles: [
{
tilesetId: BModels.ProjectViewTile.EDefaultImagery.MapBoxStreets
}
],
viewer: viewer
});
await BEngine.TileRenderEngine.Terrain.Navigator.Render({
tile: {
tilesetId: BModels.ProjectViewTile.EDefaultTerrain.FlatTerrain
},
viewer: viewer
});
BEngine.ViewerUtils.InitViewer({
viewer: viewer,
// Call if you're seeing default Cesium widgets!
destroyWidgets: false,
// This will generate default Nextspace widgets.
nextspaceWidgets: true
});
// Fly near some land.
viewer.scene.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(174.863, -36.99785, 5000),
duration: 0
});
let curStyleId = 1;
const styleIds = [1, 2];
const rendered = await...