index。html
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>模型查看</title>
<link href="./Cesium/Widgets/widgets.css" rel="stylesheet">
<script src="./Cesium/Cesium.js"></script>
<script src="./jquery.min.js"></script>
<script type=" text/javascript" src="./require.min.js" data-main="js/main"></script>
</head>
====
export default {
name: 'HelloWorld',
methods: {
query: function () {
var promise = scene.open("http://localhost:8090/iserver/services/3D-DaoDongShuJu/rest/realspace")
Cesium.when.all(promise, function (layer) {
layer = scene.layers.find('test');
// console.log(layer)
layer.indexedDBSetting.isAttributesSave = true;
// var a = layer.getAttributesById(17);
// console.log(a);
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); //设置鼠标左键单击回调事件
handler.setInputAction(function (e) {
console.log("handler")
var ids = layer.getSelection();
console.log(ids);
for (var i = 0; i < ids.length; i++) {
layer.getAttributesById(ids[i]).then(function (data) {
console.log(data);
});
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
},
function (e) {
if (widget._showRenderLoopErrors) {
var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
widget.showErrorPanel(title, undefined, e);
}
})
},
}
}