Cesium Vue(八)— 加载kml数据
是一种文件格式,用于在地球浏览器(例如 Google 地球、Google 地图和 Google 地图移动版)中显示地理数据。地标、地面叠加层、路径和多边形都可以直接在 Google 地球中编写。
·
1. KML
KML 是一种文件格式,用于在地球浏览器(例如 Google 地球、Google 地图和 Google 地图移动版)中显示地理数据。
地标、地面叠加层、路径和多边形都可以直接在 Google 地球中编写。
简单地标的 KML (类似XML)代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"> <Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark> </kml>
2. 加载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);
});

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。
更多推荐
所有评论(0)