118 lines
4.4 KiB
HTML
118 lines
4.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<script src="./Build/Cesium/Cesium.js"></script>
|
||
<link href="./Build/Cesium/Widgets/widgets.css" rel="stylesheet" />
|
||
<style>
|
||
@import url(./Build/Cesium/Widgets/widgets.css);
|
||
html,
|
||
body,
|
||
#cesiumContainer {
|
||
width: 100%;
|
||
height: 100%;
|
||
margin: 0;
|
||
padding: 0;
|
||
overflow: hidden;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div id="cesiumContainer"></div>
|
||
<script>
|
||
Cesium.Ion.defaultAccessToken =
|
||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5ZjRjNTZkNC01NDYxLTRhMjQtOGEwZC1kZjA3YzQ5YTJlZDkiLCJpZCI6MjYwODQsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1ODcxOTMwODN9.prGsSKyAW_9Ow5zHYPhbm3LsQL-ApQw5-5PNJkDaHi8";
|
||
var viewer = new Cesium.Viewer("cesiumContainer", {
|
||
// terrainProvider: Cesium.createWorldTerrain({
|
||
// requestVertexNormal: true, //添加地形光照
|
||
// requestWaterMask: true, //添加水面波浪效果
|
||
// }),
|
||
// baseLayerPicker: false, //底图选择器
|
||
// mapProjection : new Cesium.WebMercatorProjection(),
|
||
|
||
// geocoder:false,//位置查找
|
||
// homeButton:false,//视图返回初始位置
|
||
// sceneModePicker:false,//视角选择器
|
||
// navigationHelpButton:false,//导航帮助按钮
|
||
// animation:false,//动画控制器
|
||
// // creditContainer:"credit",//版权显示,指定dom对象的id,再通过id样式可以隐藏CESIUM 版本图标
|
||
// timeline:false,//时间线
|
||
// fullscreenButton:false,//全屏控件
|
||
// vrButton:false,
|
||
// infoBox:true ,
|
||
// shouldAnimate:true,
|
||
// scene3DOnly:true,//默认false,若为true,所有几何体实例将仅会在3D模式中渲染(在GPU内存中)
|
||
// terrainProvider: Cesium.createWorldTerrain({
|
||
// requestVertexNormal: true, //添加地形光照
|
||
// requestWaterMask: true, //添加水面波浪效果
|
||
// }),
|
||
});
|
||
viewer.imageryLayers.removeAll();
|
||
// 添加 Mapbox tile provider
|
||
const mapboxAccess =
|
||
"pk.eyJ1IjoicWl1c2hpamllIiwiYSI6ImNsMDNvdDRybDEyc2YzZG9kbWZoY2FuOW0ifQ.4FH-BUupi46Z0zQ-CEm_Ig";
|
||
|
||
// 样式id查看:https://docs.mapbox.com/api/maps/styles/
|
||
// URL格式的 mapbox://styles/:owner/:style, 其中 :owner 是您的 Mapbox 账户名 :style 是样式 ID 。
|
||
// 可选值:streets-v10、outdoors-v10 、light-v9、dark-v9、satellite-v9、satellite-streets-v10
|
||
const mapboxStyleImagery = new Cesium.MapboxStyleImageryProvider({
|
||
styleId: "dark-v9",
|
||
accessToken: mapboxAccess,
|
||
// proxy: new Cesium.DefaultProxy("http://127.0.0.1:8080/proxy/"),
|
||
});
|
||
viewer.imageryLayers.addImageryProvider(mapboxStyleImagery);
|
||
var scene = viewer.scene;
|
||
|
||
viewer.camera.flyTo({
|
||
destination: Cesium.Cartesian3.fromDegrees(114.91145257593077, 32.36093602262491,40000),
|
||
orientation: {
|
||
heading: Cesium.Math.toRadians(0),
|
||
pitch: Cesium.Math.toRadians(-90),
|
||
roll: Cesium.Math.toRadians(0),
|
||
},
|
||
});
|
||
|
||
// 加载淮河水系面
|
||
let url = "http://localhost:8088/geoserver/allRegion/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=allRegion%3Axixian&maxFeatures=9999&outputFormat=application%2Fjson";
|
||
fetch(url).then(res=>res.json()).then(result=>{
|
||
console.log(result)
|
||
result.features.forEach(feature=>{
|
||
addGlowFeature(feature)
|
||
})
|
||
})
|
||
|
||
function addGlowFeature(feature){
|
||
let geometryType = feature.geometry.type;
|
||
let coord = feature.geometry.coordinates;
|
||
let geometryName = feature.geometry_name;
|
||
|
||
if(geometryType == "MultiPolygon"){
|
||
let polygon = coord[0];
|
||
// 只取外环,构造边界线
|
||
|
||
polygon[0].forEach(coord=>{
|
||
|
||
})
|
||
var glowingLine = viewer.entities.add({
|
||
name: "具有发光效果的线",
|
||
polyline: {
|
||
positions: Cesium.Cartesian3.fromDegreesArray(polygon[0].flat(2)),
|
||
width: 10,
|
||
material: new Cesium.PolylineGlowMaterialProperty({
|
||
glowPower: 0.2,
|
||
color: Cesium.Color.RED,
|
||
}),
|
||
followSurface: false, //是否贴着地表
|
||
},
|
||
});
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
</script>
|
||
</body>
|
||
</html>
|