导出 KML
js
// 导出KML
var entity = viewer.entities.add({
name: "My Point",
position: Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
point: {
pixelSize: 10,
color: Cesium.Color.RED,
},
});
Cesium.exportKml({
entities: viewer.entities,
}).then(function (res) {
console.log(res);
var blob = new Blob([res.kml], {
type: "application/vnd.google-earth.kml+xml;charset=utf-8",
});
var url = URL.createObjectURL(blob);
var link = document.createElement("a");
link.href = url;
link.download = "export.kml";
// 触发下载
link.click();
});