KML 是一种文件格式,用于在地球浏览器(例如 Google 地球、Google 地图和 Google 地图移动版)中显示地理数据。
地标、地面叠加层、路径和多边形都可以直接在 Google 地球中编写。
简单地标的 KML (类似XML)代码如下:
<kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark>
<name>Simple placemarkname>
<description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0coordinates>
Point>
Placemark> kml>
这里用到2008各国人均GDP数据,文件格式为.kmz。
实现脚本
// 加载kml数据
let kmlUrl = "./Assets/gdpPerCapita2008.kmz";
let kmlDataPromise = Cesium.KmlDataSource.load(kmlUrl);
console.log(kmlDataPromise);
kmlDataPromise.then(function (dataSource) {
console.log(dataSource);
viewer.dataSources.add(dataSource);
});
