Hi there,
I want to create a basic interface to load path folder or path file like on the picture:
My code is the following:
const viewer = new Cesium.Viewer(“cesiumContainer”);
const viewModel = {
path: ‘’,
subscription: null // Ajouter une propriété pour stocker la souscription
};
Cesium.knockout.track(viewModel);
const toolbar = document.getElementById(“toolbar”);
Cesium.knockout.applyBindings(viewModel, toolbar);
const geojsonButton = function() {
// delete the subscription before create a new one
if (viewModel.subscription) {
viewModel.subscription.dispose();
}
viewModel.subscription = Cesium.knockout
.getObservable(viewModel, “path”)
.subscribe(function (path) {
if (path === “”) {
console.log(“Enter a new path”);
return;
}
var source1 = path;
console.log("The new path for the Geojson file is : " + source1);
});
};
const kmlButton = function () {
// delete the subscription before create a new one
if (viewModel.subscription) {
viewModel.subscription.dispose();
}
viewModel.subscription = Cesium.knockout
.getObservable(viewModel, “path”)
.subscribe(function (path) {
if (path === “”) {
console.log(“Enter a new path”);
return;
}
var source2 = path;
console.log("The new path for the Kml folder is: " + source2);
});
};
Sandcastle.addDefaultToolbarButton(“Geojson”, geojsonButton);
Sandcastle.addDefaultToolbarButton(“Dossier kml”, kmlButton);
I succeed to create what i want but i have a tricky problem, the first iteration of a button is wrong:
The new path for the Kml folder is: geojson1
The new path for the Geojson file is : geojson2
The new path for the Geojson file is : kml1
The new path for the Kml folder is: kml2
The new path for the Kml folder is: kml3
for exemple for geojson1, I write this and i click on the geojson button
and for kml2, I write kml2 and i click for the second time on the kml button.
Do you have explanations ? Or even solutions ?
Thanks