2025-03-19 02:51:24 +00:00
|
|
|
<!--********************************************************************
|
|
|
|
* by jiawanlong
|
|
|
|
*********************************************************************-->
|
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8" />
|
2025-03-19 03:00:22 +00:00
|
|
|
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css">
|
|
|
|
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
|
2025-03-19 02:51:24 +00:00
|
|
|
<script src="./turf.min.js"></script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
|
|
|
|
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
2025-05-18 11:30:00 +00:00
|
|
|
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjM2EzNGJmNy02N2RmLTQ0MDMtYjI2MS1hZTJiMTIwZGYwMTYiLCJpZCI6MzA0MzEyLCJpYXQiOjE3NDc3MjM3MTV9.ePQNhuoVuDsi_z00lTm5W26wyW1Adcr1AWetGM6WSXI'
|
2025-03-19 02:51:24 +00:00
|
|
|
const viewer = new Cesium.Viewer('map', {});
|
|
|
|
var points = turf.randomPoint(50, { bbox: [100, 20, 101, 21] });
|
|
|
|
|
|
|
|
for (var i = 0; i < points.features.length; i++) {
|
|
|
|
points.features[i].properties.z = ~~(Math.random() * 9);
|
|
|
|
}
|
2025-03-19 03:02:36 +00:00
|
|
|
|
2025-03-19 02:51:24 +00:00
|
|
|
points.features.push({
|
|
|
|
type: 'Feature',
|
|
|
|
geometry: {
|
|
|
|
type: 'Point',
|
|
|
|
coordinates: [100, 20]
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
z: 5
|
|
|
|
}
|
|
|
|
});
|
|
|
|
points.features.push({
|
|
|
|
type: 'Feature',
|
|
|
|
geometry: {
|
|
|
|
type: 'Point',
|
|
|
|
coordinates: [101, 20]
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
z: 3
|
|
|
|
}
|
|
|
|
});
|
|
|
|
points.features.push({
|
|
|
|
type: 'Feature',
|
|
|
|
geometry: {
|
|
|
|
type: 'Point',
|
|
|
|
coordinates: [101, 21]
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
z: 4
|
|
|
|
}
|
|
|
|
});
|
|
|
|
points.features.push({
|
|
|
|
type: 'Feature',
|
|
|
|
geometry: {
|
|
|
|
type: 'Point',
|
|
|
|
coordinates: [100, 21]
|
|
|
|
},
|
|
|
|
properties: {
|
|
|
|
z: 2
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var tin = turf.tin(points, 'z');
|
|
|
|
var promise = Cesium.GeoJsonDataSource.load(tin, {});
|
|
|
|
promise.then(function (dataSource) {
|
|
|
|
viewer.dataSources.add(dataSource);
|
|
|
|
var entities = dataSource.entities.values;
|
|
|
|
for (var o = 0; o < entities.length; o++) {
|
|
|
|
var r = entities[o];
|
|
|
|
r.polygon.material = Cesium.Color.fromRandom({
|
|
|
|
alpha: 0.7
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
viewer.flyTo(promise);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|