# About how to get the UCustomCesiumGeoJsonOverlay by C++

**URL:** <https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179>\
**Category:** Cesium for Unreal\
**Created:** [May 12, 2026, 1:42am UTC](https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179 "2026-05-12T01:42:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![libo19921114](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/libo19921114/32/28173_2.png) [@libo19921114](https://community.cesium.com/u/libo19921114)\
**Post date:** [May 12, 2026, 1:42am UTC](https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179/1 "2026-05-12T01:42:40Z")

</div>

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.

 ![无标题2](https://global.discourse-cdn.com/cesium/original/3X/4/7/47da0a633271491c5d85eddcceca25dfe80b1b1e.png)

---

<div class="post-metadata">

**Author:** ![darcyvdd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@darcyvdd](https://community.cesium.com/u/darcyvdd)\
**Post date:** [May 13, 2026, 5:59am UTC](https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179/2 "2026-05-13T05:59:06Z")

</div>

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:

```cpp
// 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:

```cpp
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!

---

<div class="post-metadata">

**Author:** ![libo19921114](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/libo19921114/32/28173_2.png) [@libo19921114](https://community.cesium.com/u/libo19921114)\
**Post date:** [May 13, 2026, 7:33am UTC](https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179/3 "2026-05-13T07:33:03Z")

</div>

**[darcyvdd](https://community.cesium.com/u/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!

 ![无标题.3png](https://global.discourse-cdn.com/cesium/original/3X/4/d/4d6eb5c0efea1c69d07b7f00bfbc40960fb16752.png)

---

<div class="post-metadata">

**Author:** ![darcyvdd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@darcyvdd](https://community.cesium.com/u/darcyvdd)\
**Post date:** [June 23, 2026, 1:55am UTC](https://community.cesium.com/t/about-how-to-get-the-ucustomcesiumgeojsonoverlay-by-c/46179/4 "2026-06-23T01:55:59Z")

</div>

Thanks for sharing the code! Two things:

**For click identification:**

The `MaterialLayerKey` won’t help here. It controls how overlays blend in the material graph, not click identity. And as I mentioned before, raster overlays don’t expose which one was “hit” from a line trace.

The practical approach is to work with geography. When your line trace hits the tileset:

1. Get the hit location in world space (`HitResult.ImpactPoint`)
2. Convert it to longitude/latitude using your `ACesiumGeoreference` actor:

```cpp
FVector LLH = Georeference->TransformUnrealPositionToLongitudeLatitudeHeight(HitResult.ImpactPoint);
// LLH.X = longitude, LLH.Y = latitude, LLH.Z = height

```

3. Check which Area in your list contains that geographic point

If your Area struct already carries the GeoJSON bounds you’re loading per area, you can reuse that directly. If the areas don’t overlap, a bounding box check is usually enough. If they do overlap, you’d need a point-in-polygon test against the GeoJSON geometry.
