Hello all,
figure it out how to add points from Geoserver, not as xxx.kml file but as wms/kml?layers.
But now have a “little” problem with removing selected poi layer from view.
For each poi layer using same button for add/remove points, first click add points, and second click remove points from scene.
Everything works fine with adding layers, but cannot make it work to remove just that clicked layer from scene…so far only removeAll works … but that’s not what I need since it removes all shown poi layers.
Read other posts about removing KML but cannot reproduce it in my case, as you can see in code.
+++++ Working code with removeAll +++++
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
// sceneMode : Cesium.SceneMode.COLUMBUS_VIEW,
sceneMode : Cesium.SceneMode.SCENE3D,
animation : false,
timeline : false,
infoBox : true,
baseLayerPicker: false,
sceneModePicker: false,
imageryProvider: false,
vrButton : true,
homeButton : false
});
//------------------------- KML POI initialization ------------------------------------------------
var optionsKML = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas,
clampToGround: true
};
//var dataSource1 = new Cesium.KmlDataSource();
//dataSource1.load(‘http://xxxx.xxxx.xxx/geoserver/wms/kml?layers=castles_3d1’, optionsKML);
//------------------------- KML POI initialization ------------------------------------------------
… code code code …
//----------------------on/off poi kml castles … -------------------------------------
var dvorci;
function poi1() {
if (dvorci) {
// viewer.dataSources.remove(dataSource1);
viewer.dataSources.removeAll();
dvorci = null;
} else {
// dvorci = viewer.dataSources.add(dataSource1);
dvorci = viewer.dataSources.add(Cesium.KmlDataSource.load(‘http://xxxx.xxxx.xxx/geoserver/wms/kml?layers=castles_3d1’, optionsKML));
}
}
**//----------------------on/off poi kml castles … -------------------------------------
//----------------------on/off Alpine huts … ------------------------------------- **
var pk;
function hut() {
if (pk) {
viewer.dataSources.removeAll();
pk = null;
} else {
pk = viewer.dataSources.add(Cesium.KmlDataSource.load(‘http://xxxx.xxxx.xxx/geoserver/wms/kml?layers=Alpine_huts’, optionsKML));
}
}
**//----------------------on/off Alpine huts … -------------------------------------**Hope the explanation of the issue is clear enough !Please help me to fix this issue.
Thx in advance,
Davor