代码
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta http-equiv="X-UA-Compatiable" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
<title>3DViewer</title>
<link rel="stylesheet" type="text/css" href="./css/pretty.css"/>
<link href="./css/widgets.css" rel="stylesheet">
<link href="./css/bootstrap.min.css" rel="stylesheet">
<script src="./js/jquery.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/bootstrap-select.min.js"></script>
<script src="./js/config.js"></script>
<script type="text/javascript" src="./js/require.min.js" data-main="js/main"></script>
<script src="./Build/Cesium/Cesium.js"></script>
</head>
<body>
<div id="cesiumContainer" style="width:100%;height:100%"></div>
<blockquote id="bubble" class="bubble">
<h2 id="title"></h2>
<p id="des" class="word"></p>
</blockquote>
<script type="text/javascript">
function onload(Cesium){
var viewer = new Cesium.Viewer('cesiumContainer');
var infoboxContainer = document.getElementById("bubble");
var scene = viewer.scene;
var camera =viewer.camera;
var canvas = scene.canvas;
$('#loadingbar').remove();
var widget = viewer.cesiumWidget;
var promise =scene.open("http://localhost:8090/iserver/services/3D-picCBD/rest/realspace");
Cesium.when(Promise,function(layers){
if(!scene.pickPositionSupported){
alert('不支持深度拾取,属性查询功能无法使用!');
}
//设置属性查询参数
var layer =scene.layers.find('CBD');
console.log(layer);
layer.setQueryParameter({
url:'http://localhost:8090/iserver/services/data-picCBD/rest/data',
dataSourceName:'CBD',
dataSetName:'Building',
keyWord:'SmID'
});
camera.setView({
destination: Cesium.Cartesian3.fromDegrees(116.4581, 39.9122, 2000)
});
});
//添加自定义infobox
var title = document.getElementById("title");
var des =document.getElementById("des");
//注册鼠标点击事件
viewer.pickEvent.addEventListener(function(feature){
console.log("测试");
var ti =Cesium.defaultValue(feature.MODELNAME,'');
var ds =Cesium.defaultValue(feature.SmID,'');
title.innerText=ti;
des.innerText=ds;
});
}
</script>
</body>
</html>
<!--StartFragment -->
如图 console输出结果是undefined
这代表数据有问题嘛
请教老师! 谢谢了!