加载的是官网给出的cbd模型,想把Building@CBD里面的ModelName字段信息展示到3D模型上
代码:
var viewer = new Cesium.Viewer('cesiummap');
//设置相机位置、视角
viewer.scene.camera.flyTo({
destination : Cesium.Cartesian3.fromDegrees(116.45939, 39.915676, 5000),
orientation : {
heading : 5.462824916628415,
pitch :-1.5695598976662626,
roll : 6.2831853071570976
}
});
var scene = viewer.scene;
var widget = viewer.cesiumWidget;
viewer.scene.sun.show = false;
try {
//开启泛光和HDR
viewer.scene.bloomEffect.show = true;
viewer.scene.hdrEnabled = true;
viewer.scene.bloomEffect.threshold = 0.8;
viewer.scene.bloomEffect.bloomIntensity = 1;
var promise= viewer.scene.open('https://www.supermapol.com/proxy/realspace/services/3D-CBD/rest/realspace');
//var promise = scene.open('http://www.supermapol.com/realspace/services/3D-ZhongGuoDiTu/rest/realspace');
Cesium.when.all(promise, function (layers) {
//var layer0 = scene.layers.find("ProvinceCity@中国地图");
var layer0 = scene.layers.find("Building@CBD");
console.log(layer0.labelStyle);
layer0.indexedDBSetting.isAttributesSave = true;//保存属性
layer0.showLabel = true;
layer0.labelStyle = new Cesium.S3MTilesLabelStyle({
fillColor: Cesium.Color.WHITE,
outlineColor: Cesium.Color.RED,
font: '44px Calibri',
outlineWidth: 5.0,
scale: 0.4,
fillStyle: Cesium.LabelStyle.FILL_AND_OUTLINE,
textField: 'ModelName',
pixelOffset: new Cesium.Cartesian2(0, -5)
});
});
}catch (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}
页面效果图:
可以看到ModelName字段的信息没有展示出来
我希望能做成把CBD模型名上面用边界线线划分成一个一个的区域,并且标注出区域名称,例如下图
老师帮忙看一下上面的代码,跟官网的示例代码基本一致,但就是没有出来希望看到的效果,看看是哪里出问题了
非常感谢您