Skip to content

Commit

Permalink
patch for cesium
Browse files Browse the repository at this point in the history
  • Loading branch information
sidqian123 committed May 2, 2024
1 parent 30b0a06 commit 743bcb4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions js_component/cesium.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Initialize the Cesium Viewer
let apiKey = localStorage.getItem('cesiumApiKey');
Cesium.Ion.defaultAccessToken = apiKey;
var viewer = new Cesium.Viewer('cesiumContainer', {
animation: false,
baseLayerPicker: false,
Expand Down
16 changes: 16 additions & 0 deletions js_component/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,19 @@ document.addEventListener('DOMContentLoaded', function() {
updateWindowsDropdown();
});

document.getElementById('uploadAPI').addEventListener('click', function(event) {
// Retrieve the API key from the input element
var apiKey = document.getElementById('cesiumAPI').value;

try {
// Save the API key in localStorage
localStorage.setItem('cesiumApiKey', apiKey);
Cesium.Ion.defaultAccessToken = apiKey;
// reload the page to apply the changes
location.reload();
console.log('API Key saved successfully');
} catch (error) {
console.error('Failed to save API Key', error);
}
});

4 changes: 4 additions & 0 deletions mainWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ <h2>User Preference</h2>
<label for="commandFile">Command JSON file upload:</label>
<input type="file" id="commandFile" accept=".json">
<br><br>
<label for="cesiumAPI">Cesium API upload:</label>
<input type="text" id="cesiumAPI" >
<button id="uploadAPI">Save</button>
<br><br>
<button id="closePref">Close</button>
</div>
</div>
Expand Down

0 comments on commit 743bcb4

Please sign in to comment.