之前都是用 原生的XMLHttpRequest对象 加载geojson数据,
const req = new XMLHttpRequest();
req.open("get", "POINT.geojson");
req.send(null);
req.onload = function () {
var data = JSON.parse(req.responseText);
data.features.forEach((feature) => {
});
}
步骤较为繁琐,频繁调用使用
$.get("POINT.geojson", function(data) {
data.features.forEach((feature) => {
// 对feature进行操作
});
});
其他问题
若报错:
trailWallPositions是[ [ ],[ ],[ ],[ ],[ ],[ ] ]这个形式
message: "the number of coordinates must be a multiple of 2 and at least
则需要以完全扁平化多维数组,使用
positions: Cesium.Cartesian3.fromDegreesArray(
trailWallPositions.flat()
),
若 报错maximumHeights must have the same length.等等