使用产品:iserver 10i 操作系统:win10
数据类型: 文件型
问题详细描述:我修改了官网的倾斜摄影模型的部分代码,只能加载到发布的三维模型,但是点击无触发事件,修改后的代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" 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>属性查询</title>
<link href="../Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<link href="./css/pretty.css" rel="stylesheet">
<script src="./js/jquery.min.js"></script>
<script src="./js/config.js"></script>
<script type="text/javascript" src="./js/require.min.js" data-main="js/main"></script>
</head>
<body>
<div id="cesiumContainer"></div>
<div id='loadingbar' class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
</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 infoboxContainer = document.getElementById("bubble");
//初始化viewer部件
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
url : 'https://dev.virtualearth.net',
mapStyle : Cesium.BingMapsStyle.AERIAL,
key : URL_CONFIG.BING_MAP_KEY
}));
viewer.customInfobox = infoboxContainer;
var scene = viewer.scene;
var canvas = scene.canvas;
var widget = viewer.cesiumWidget;
$('#loadingbar').remove();
try {
//添加S3M图层服务
var promise = scene.open('http://localhost:8090/iserver/services/3D-project/rest/realspace');
Cesium.when(promise, function (layers) {
if(!scene.pickPositionSupported){
alert('不支持深度拾取,属性查询功能无法使用!');
}
var layer = scene.layers.find('project');
//设置属性查询参数
layer.setQueryParameter({
url: 'http://localhost:8090/iserver/services/data-project/rest/data',//这里我填入的为发布的3D服务对应的数据服务,不知道对不对
dataSourceName: 'project',
dataSetName: 'test',
keyWord: 'SmID'
});
//设置相机视角
scene.camera.setView({
//将经度、纬度、高度的坐标转换为笛卡尔坐标
destination : new Cesium.Cartesian3(-2767302.844416157,5085941.49155452,2675759.1559041184),
orientation : {
heading : 4.7793869967010565,
pitch : -0.5899023527373464,
roll : 8.539835505416704e-12
}
});
}, function (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
});
}
catch (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}
//添加自定义infobox
var title = document.getElementById("title");
var des = document.getElementById("des");
var myimg = document.getElementById("myimg");
//注册鼠标点击事件
viewer.pickEvent.addEventListener(function(feature){
console.log(feature);
var title = Cesium.defaultValue(feature.NAME,'');
var description=new Array();
description[0]=Cesium.defaultValue("SMID:"+feature.SMID,'');
description[1]=Cesium.defaultValue("SMSDRIW:"+feature.SMSDRIW,'');
description[2]=Cesium.defaultValue("SMSDRIN:"+feature.SMSDRIN,'');
description[3]=Cesium.defaultValue("ELEMENTID:"+feature.ELEMENTID,'');
title.innerText = title;
des.innerText = description;
});
}
</script>
</body>
</html>
我试过打印的方式来调试程序,只能打印到 //注册鼠标点击事件 viewer.pickEvent.addEventListener(function(feature)前一行,不知道哪里错了,还请赐教。