# Html overlays in 3d terrain

**URL:** <https://community.cesium.com/t/html-overlays-in-3d-terrain/34489>\
**Category:** CesiumJS\
**Created:** [August 13, 2024, 7:04am UTC](https://community.cesium.com/t/html-overlays-in-3d-terrain/34489 "2024-08-13T07:04:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetukhovArt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/petukhovart/32/23829_2.png) [@PetukhovArt](https://community.cesium.com/u/PetukhovArt)\
**Post date:** [August 13, 2024, 7:04am UTC](https://community.cesium.com/t/html-overlays-in-3d-terrain/34489/1 "2024-08-13T07:04:35Z")

</div>

Hello , i have the collection of html overlays with huge logic , which I display on map.  
When I use terrain provider arcGis or Cesium , and trying to press ctrl and turn over the view of map, my overlays are moving , but there position is same… , height of each overlay = 0

example

> **[Cesium Sandcastle](https://sandcastle.cesium.com/#c=bVLrc6IwEP9XMnzCOS+inrUP61xLexbHRx9ozw4zHQwRIiGhSbDFm/7vF8D26rWfYHd/j93N2liSLIEOZzDAKz+j6gwhLKXLY8zAKfAMnA+j5QCRKRk6s63TnBBHOuy2g2znwInT33N7eAQ16CkYxBrkdBatmfXgxq0Jaa4n2yAeuTft6f1CLdbzZHFn5ePBuL1w4/ZkHW7HyYyM7GH6oMUm67gzyZ8Jak02aDDfOut06SS/tqgwTIK1Qy39pVGgsWN3Zk0vzppjF1nTKwvaMj/I8zO2ORjenafplTXN2n4koyd09esyum51yXTbCdc340vuGSce8xjiTCqwIfgZCz0nw8/ArnYxL3OmZ6AytjlTPmFYeEYd/PEYAAoLoTPHbwS3iuFK8OSeCxrsEmat7rHXWmm38QWIVEKnGyyon2vHgKMswUzBEKtLiovf89wJtO8HnGcU9IIskfAVivZbtX2h9J/PWmaJKzuHEmGGYSrwLWaBjv0guNxo+RGRSleEucoYUoQzYNaqiQqDlEtSJk8/qbfL0S5wKDCW5vduB3aOut1uHfywoNU+PGwX5pUK8nW38vqf1l5P6E3R5XYJtDkXAWG+zpqFBHhvo16Fu7GLoDIhK2Du+tMHq98lMPc9a7uZwMd9Q6lyiqHiqW5pHw9z8E2fefpSHsbXPIpX6jPxZZ/4untso270Slq/kgPgJ0lSLhTIBDUhbCicpLQYubHMUIwVRFLWdt69xkdqLyAbQILTL24RIOpLqSurjNI7ssWe0e81NP4TlXJfrzh8v6h+L2r2R1USQthr6PBrpuKcLn3xvzJJwqq+d6igbFxn317wGPhLyWmm8ElRFUjX9PQk8UM9evWGjyMe8ke+W3bKQu31Fw)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

Can I suggest something to fix this ?

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [August 14, 2024, 8:15pm UTC](https://community.cesium.com/t/html-overlays-in-3d-terrain/34489/2 "2024-08-14T20:15:17Z")

</div>

Hi there,

It looks like the overlays are a an ellipsoid height of 0, meaning they are actually _under_ terrain, causing the discrepancy in the visuals.

To display the overlays at the height which corresponds to terrain, I would suggest using [picking](https://sandcastle.cesium.com/?src=Picking.html&label=All) in the event listener callback.

---

<div class="post-metadata">

**Author:** ![PetukhovArt](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/petukhovart/32/23829_2.png) [@PetukhovArt](https://community.cesium.com/u/PetukhovArt)\
**Post date:** [August 15, 2024, 6:04am UTC](https://community.cesium.com/t/html-overlays-in-3d-terrain/34489/3 "2024-08-15T06:04:54Z")

</div>

but then I will have to change the entire logic of the widget, which is very labor-intensive, is there any option to determine the correct height for the html-overlay?

such problem exists only with using html-overlays ?

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [August 16, 2024, 5:36pm UTC](https://community.cesium.com/t/html-overlays-in-3d-terrain/34489/4 "2024-08-16T17:36:16Z")

</div>

Hi @PetukhovArt,

I don’t think this should be a major overhaul, but I probably lack the context of the overall widget design. Could you explain a bit more?

For clarity, an HTML overlay is more or less standard DOM manipulation outside CesiumJS. The CesiumJS portion involves mapping the in-world 3D position to a 2D screenspace position that the DOM element can map to.

From the code you posted, it looks like you are using `Cartesian3` instances to represent the in-world 3D position. These instances are simply X/Y/Z coordinates and don’t “know” anything about the terrain. In order to incorporate terrain height, you’ll need to sample it somehow. Picking, as I suggested above, is a common method. But there are alternatives such as asynchronously making network request to sample the exact height of terrain.
