# Picking Sand Castle Example doesn't work with Terrain

**URL:** <https://community.cesium.com/t/picking-sand-castle-example-doesnt-work-with-terrain/3071>\
**Category:** CesiumJS\
**Created:** [September 16, 2015, 6:50pm UTC](https://community.cesium.com/t/picking-sand-castle-example-doesnt-work-with-terrain/3071 "2015-09-16T18:50:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunny\_Little](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@Sunny\_Little](https://community.cesium.com/u/Sunny_Little)\
**Post date:** [September 16, 2015, 6:50pm UTC](https://community.cesium.com/t/picking-sand-castle-example-doesnt-work-with-terrain/3071/1 "2015-09-16T18:50:05Z")

</div>

Hello,  
I was looking at the Picking Sandcastle example, and I noticed that in the ‘Show Cartographic Position on Mouse Over’ example that if I ‘turned on’ terrain, STK World Terrain meshes, the label would not stay above the terrain and would be hidden depending on the mouse position.

I’m also seeing a similar issue in a cesium app I’m working on.

What is your recommendation for solving this issue?

Regards,

Sunny Little

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [September 17, 2015, 5:49pm UTC](https://community.cesium.com/t/picking-sand-castle-example-doesnt-work-with-terrain/3071/2 "2015-09-17T17:49:54Z")

</div>

Hello Sunny,

It’s not part of the entity API yet, but we recently added a [heightReference](http://cesiumjs.org/Cesium/Build/Documentation/Label.html#heightReference) property to labels and billboards. Setting heightReference: Cesium.HeightReference.CLAMP\_TO\_GROUND will clamp the label to the terrain. Here is an example:

var viewer = new Cesium.Viewer(‘cesiumContainer’);  
var scene = viewer.scene;

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({  
url : ‘[//assets.agi.com/stk-terrain/world](https://assets.agi.com/stk-terrain/world)’  
});  
viewer.terrainProvider = cesiumTerrainProviderMeshes;  
viewer.scene.globe.depthTestAgainstTerrain = true;

var labels = scene.primitives.add(new Cesium.LabelCollection({  
scene : viewer.scene  
}));  
var label = labels.add({  
text: ‘My Label’,  
position: Cesium.Cartesian3.fromDegrees(-120, 40),  
heightReference: Cesium.HeightReference.CLAMP\_TO\_GROUND,  
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,  
horizontalOrigin: Cesium.HorizontalOrigin.CENTER  
});

viewer.scene.camera.setView({  
position: new Cesium.Cartesian3(-2448719.8735619076, -4250107.43283317, 4067838.088739029),  
heading: 5.999866663850403,  
pitch: 0.04494318727342117,  
roll: 6.282261310513073  
});

``

Best,

Hannah
