I have an app with 2 splitted map, a 3D and a 2D one.
At some point I load a KML from and external server, and do the following :
loadKml(): Observable<Cesium.KmlDataSource> {
this.dataService
.getKmls()
.pipe(
map((data) => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(data, "text/xml");
const kml = new Cesium.KmlDataSource();
kml.load(xmlDoc);
return kml;
})
)
}
Now, this is supposed to be just a KMLDataSource, stored somewhere in my app. I then, in both of my map, load this source.
...
this.loadKml().subscribe((KMLDataSource) =>
Cesium.when(this.viewer.dataSources.add(KMLDataSource))
)
...
but this do no work, it load the KML in a single map only. and the second one even tho it add something, never display it.
If instead of doing this, I return the kml xml, and create 2 separated datasource, it works
loadKml(): Observable<Cesium.KmlDataSource> {
this.dataService
.getKmls()
.pipe(
map((data) => {
const parser = new DOMParser();
return parser.parseFromString(data, "text/xml");
})
)
}
this.loadKml().subscribe((xml) => {
const kml = new Cesium.KmlDataSource();
kml.load(model.getData());
Cesium.when(this.viewer.dataSources.add(xml))
})
Now, I know that the options for KMLDatasource are viewer.camera and viewer.canvas, so it does sound like it’s bounded to a map, but I am a bit confused on why. KMLDataSource just sound like it’s a datasource of kml, and should not be related to a camera/canvas/map in particular. Why is this the case ?