pickImageryLayerFeatures
suspend fun pickImageryLayerFeatures(ray: Ray, scene: Scene): ReadonlyArray<ImageryLayerFeatureInfo>?(source)
Asynchronously determines the imagery layer features that are intersected by a pick ray. The intersected imagery layer features are found by invoking ImageryProvider.pickFeatures for each imagery layer tile intersected by the pick ray. To compute a pick ray from a location on the screen, use Camera.getPickRay.
const pickRay = viewer.camera.getPickRay(windowPosition);
const featuresPromise = viewer.imageryLayers.pickImageryLayerFeatures(pickRay, viewer.scene);
if (!Cesium.defined(featuresPromise)) {
console.log('No features picked.');
} else {
Promise.resolve(featuresPromise).then(function(features) {
// This function is called asynchronously when the list if picked features is available.
console.log(`Number of features: ${features.length}`);
if (features.length 0) {
console.log(`First feature name: ${features[0].name}`);
}
});
}
Content copied to clipboard
Return
A promise that resolves to an array of features intersected by the pick ray. If it can be quickly determined that no features are intersected (for example, because no active imagery providers support ImageryProvider.pickFeatures or because the pick ray does not intersect the surface), this function will return undefined.
Parameters
ray
The ray to test for intersection.
scene
The scene.