Hello. I’m developer using cesium js to display 3d building models.
async function loadData() {
try {
const extent = getCurrentExtent3D();
if(extent && !isBuildingLoading) {
console.log("loading start");
let geoJsonGBuildings = geoserverOwsUrl + '?service=WFS&version=1.0.0&request=GetFeature&typeName=gucms%3Ag_buildings_with_img&maxFeatures=10000&outputFormat=application%2Fjson&bbox=';
extent.forEach(function(e, i) {
geoJsonGBuildings += e;
if(i != extent.length - 1) geoJsonGBuildings += ',';
});
if(map3D.dataSources.contains(dataSourceGBuildings)) {
map3D.dataSources.remove(dataSourceGBuildings);
}
isBuildingLoading = true;
dataSourceGBuildings = await Cesium.GeoJsonDataSource.load(geoJsonGBuildings, {
clampToGround: false,
});
dataSourceGBuildings.changedEvent = function() {
console.log("datasource changed.");
}
isBuildingLoading = false;
console.log("loaded.");
map3D.dataSources.add(dataSourceGBuildings);
} else {
return;
}
} catch (err) {
console.log("Error: ", err);
}
}
I loaded 3d geojson building datas using geoserver.
when I moved the camera, load the 3d geojson building data and add the buildings to the map.
but now, I remove all 3d buildings when i moved the camera.
I want to replace some datasources with new building data. (without removing whole data)
help me.
(variable ‘map3D’ is Cesium.Viewer)