geoserver发布服务详见:https://blog.csdn.net/weixin_43598687/article/details/124102651
var provider1 = new Cesium.WebMapServiceImageryProvider({
url:'http://localhost:8080/geoserver/test/wms', //wms服务路径
layers: 'test:dem', //图层名
parameters: {
service : 'WMS', //服务类型
format: 'image/png', //格式
srs: 'EPSG:4326', //坐标系
transparent: true, //是否透明
}
});
tifLayer = viewer.imageryLayers.addImageryProvider(provider1);
移除图层
viewer.imageryLayers.remove(tifLayer);
var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas,
clampToGround: true //开启贴地
};
viewer.dataSources.add(Cesium.KmlDataSource.load('./static/lith.kmz', options)).then(function(dataSource){
viewer.clock.shouldAnimate = false;
var rider = dataSource.entities.getById('tour');
viewer.flyTo(rider).then(function(){
viewer.trackedEntity = rider;
viewer.selectedEntity = viewer.trackedEntity;
viewer.clock.multiplier = 30;
viewer.clock.shouldAnimate = true;
});
});
移除图层
datasource = viewer.dataSources.get(viewer.dataSources.length-1);
viewer.dataSources.remove(datasource, true);
let smcPromise = Cesium.GeoJsonDataSource.load('./static/ALL.json',{
clampToGround : true, //开启贴地
});
smcPromise.then(function (dataSource){
viewer.dataSources.add(dataSource);
});
移除图层
datasource = viewer.dataSources.get(viewer.dataSources.length-1);
viewer.dataSources.remove(datasource, true);
label1 = viewer.entities.add({
id:'name1',
name:'name1',
position:Cesium.Cartesian3.fromDegrees(103.769601,33.264294), //经纬度
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, //开启贴地
billboard:{ //加载图片图标
image: './static/roadLabel.png',
height: 40,
width: 40,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
pixelOffset : new Cesium.Cartesian2(0, 0), //偏移量
},
label:{
text:'text',
font:'16pt 宋体',
fillColor:Cesium.Color.WHITE,
style: Cesium.LabelStyle.FILL,
outlineWidth : 1,
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
pixelOffset : new Cesium.Cartesian2(60, 0)
},
});