I developed an app witch cesium. currently i using drag and drop feature but i need upload automatically. I will upload local kml files to cesium KmlDataSource. i was tried to create localhost and using it but receive “Access-Control-Allow-Origin” errors.
Is there any way that i upload and display kml ?
Thank you for sharing these updates with me! I took some time to look back on some of my old source code. Something like this has worked for me in the past. Essentially, this code is supposed to ensure that only the data added is kept. You may have to tweak some of the parameters to meet the needs of your use case.
// When the user adds a new data source through drag and drop, remove the last one
viewer.dataSources.dataSourceAdded.addEventListener(function() {
if (viewer.dataSources.length > 1) {
for (let i = 0; i < viewer.dataSources.length - 1; i++) {
viewer.dataSources.remove(viewer.dataSources.get(i));
}
}
});
Here is a link to a Sandcastle demo that contains this code: