Hello everyone, I’m using Cesium for Unreal with C++ to build a scene. I upload a GeoJSON file to add an overlay to a Cesium3DTileset, but when I click the overlay, I can’t retrieve the UCustomCesiumGeoJsonOverlay information.
Hey @libo19921114, welcome to the forum! Thanks for sharing the code, that helps a lot.
I think I can see the issue. The line trace hit component (HitResult.GetComponent()) on line 156 returns the mesh primitive component that was physically hit. This is a UCesiumGltfPrimitiveComponent (the rendered tile geometry), not the raster overlay. So this cast will always return null:
// This will always fail - HitComponent is a mesh, not an overlay
UCustomCesiumGeoJsonOverlay* HitOverlay = Cast<UCustomCesiumGeoJsonOverlay>(HitComponent);
Raster overlays are not individually hittable via line traces. They’re texture layers composited onto the tileset mesh at render time. You can’t determine which overlay was “clicked” from a line trace alone.
Your GetComponentByClass approach at the bottom is the correct way to get the overlay reference:
ACesium3DTileset* HitTileset = Cast<ACesium3DTileset>(HitResult.GetActor());
if (HitTileset)
{
// This gives you the overlay component on the tileset actor
UCesiumGeoJsonDocumentRasterOverlay* Overlay =
HitTileset->FindComponentByClass<UCesiumGeoJsonDocumentRasterOverlay>();
}
If you have multiple GeoJSON overlays on the same tileset and need to distinguish which one was clicked, you’d need to check the hit location against each overlay’s geographic bounds in your own logic, the raster overlay system doesn’t provide per-pixel overlay identification.
Could you share what information you’re trying to get from the overlay? If it’s feature metadata (properties from the GeoJSON), the approach would be different, you’d use UCesiumMetadataPickingBlueprintLibrary to query feature properties at the hit point.
Cheers!
darcyvdd, thanks alot, as you said, I have multiple GeoJSON overlays on the same tileset, and need to distinguish which one was clicked.The following picture is code. Can you give me some suggestion about how to fixed it.thans u!

