Ian,
I am interested in the answer to your Q: Is there an example which includes checking if the entity is visible?
I also wanted to thank you for following up, and posting your successful tooltip result. It adds a lot of value to the forum, as a resource, when users also contribute, rather than relying solely on the valuable suggestions and code snippets provided by Hannah and the Cesium team.
In the javascript function that initializes my Cesium map, I add a number of eventHandlers, to which I added Ian’s snippet for tooltips, modified to access properties of two geoJSON datasources, as follows. I placed the getSelectedObjFromPoint function outside that initialization function.
/**++++++++++++++++++++++++++++++++++++++++*
var handlerToolTips = new Cesium.ScreenSpaceEventHandler(CesiumMapViewer.scene.canvas);
var SelectedObj= null;
handlerToolTips.setInputAction(function (movement) {
SelectedObj= getSelectedObjFromPoint(movement.endPosition);
if (SelectedObj != null) {
var obj = document.getElementById(“cesiumContainer”); obj.title = SelectedObj;
} else{
var obj = document.getElementById(“cesiumContainer”); obj.title = “”;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
function getSelectedObjFromPoint(Position){
/** credit Ian Walberg, https://groups.google.com/forum/#!topic/cesium-dev/68GDFwLYWYk
var valueToReturn= null;
var pickedObject = CesiumMapViewer.scene.pick(Position);
var pickedObjects = CesiumMapViewer.scene.drillPick(Position);
var picked = pickedObjects[0];
if (!Cesium.defined(pickedObject)) {
picked = null;
valueToReturn = null;
}
else if (pickedObject.id._properties !== undefined) {
if (pickedObject.id._properties.Path_Name !== undefined && pickedObject.id._properties.danger_rating !== undefined) {
valueToReturn = pickedObject.id._properties.Path_Name + " danger level = " + danger_level[pickedObject.id._properties.danger_rating];
}
}
else if (pickedObject.id.description !== undefined ){
valueToReturn = pickedObject.id.description._value.value;
}
return valueToReturn;
}
``