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="MY_ENTITY_PANEL">
</div>
</div>
CSS
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
#VIEWER {
width: 100%;
height: 100%;
position: relative;
}
#MY_ENTITY_PANEL {
position: absolute;
top: 10px;
right: 10px;
z-index: 1;
background: white;
color: black;
padding: 10px;
display: none;
border-radius: 6px;
width: 450px;
overflow: hidden;
}
#MY_ENTITY_PANEL >textarea {
background: transparent;
outline: none;
border: none;
width: 100%;
height: 500px;
color: black;
}
JavaScript
// Replace with your Account ID and Project View.
const ACCOUNT_ID = "openstreetmapdemo1";
const PROJECT_VIEW_ID = "913a8070";
const BOOKMARK_ID = "2b744082-4a87-4c55-9cc2-e6706a5d92d3";
// Nextspace examples don't use production, swap to true for your data.
const IS_PRODUCTION = true;
// If your Project View is not public, then this will be required for it to load.
const SESSION_ID = "anonymous";
BModels.ENVIRONMENT.Reset({
accountId: ACCOUNT_ID,
sessionId: SESSION_ID,
env: IS_PRODUCTION ? BModels.Api.EEnv.PROD : BModels.Api.EEnv.DEV
});
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", {
// Disabling any default imagery/terrain from coming in since we're rendering a bookmark right afterwards that will dictate these things.
imageryProvider: false,
baseLayerPicker: false,
terrainProvider: null,
});
BEngine.ViewerUtils.InitViewer({
viewer: viewer,
// Call if you're seeing default Cesium widgets!
destroyWidgets: false,
nextspaceWidgets: false
});
const widgets = BEngine.ViewerUtils.CreateWidgets({
viewer: viewer,
// If you don't pass "defaultState: false" then it will assume that any widget you don't specify should be created.
defaultState: false,
navCompass: true,
branding: true,
cursorBar: true,
searchBar: false,
infoView: false,
bookmarks: true
});
await BEngine.ViewRenderEngine.Render({
bookmarkId: BOOKMARK_ID,
viewId: PROJECT_VIEW_ID,
...