基于iclient3D for webGL,叠加了iServer发布的二维地图,通过鼠标点击事件能否获取到选中要素信息?有什么方法吗?
通过以下代码,发现featurePromise一直是undefined。
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(e) {
var pickRay = viewer.camera.getPickRay(e.position);
var featuresPromise = imageryLayers.pickImageryLayerFeatures(pickRay, viewer.scene);
if (!Cesium.defined(featuresPromise)) {
console.log('No features picked.');
} else {
Cesium.when(featuresPromise, function(features) {
console.log('Number of features: ' + features.length);
if (features.length > 0) {
console.log('First feature name: ' + features[0].name);
}
});
}
},Cesium.ScreenSpaceEventType.LEFT_CLICK);