Working with labels, offset and stick to entity

I’m trying to add a label to a moving entity. How can I get the label to be offset from the entity (so it’s not on top of the entity) and also “stick” to the entity as you zoom in and out?

Hi, You can use verticalOrigin and pixelOffset to set the label move along with the entity.

 label: {
        text: "Hello",
        font: '14px sans-serif',
        showBackground: true,
        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
        pixelOffset: new Cesium.Cartesian2(0, -25),
        pixelOffsetScaleByDistance : new Cesium.NearFarScalar(10, -7.0, 300, 0.0),
        distanceDisplayCondition : new Cesium.DistanceDisplayCondition(10.0, 300.0),
        scaleByDistance : new Cesium.NearFarScalar(10, 2.0, 300, 0.0)
    },

Here is the sandcastle link

You can set pixelOffsetScaleByDistance also to set offset according to zoom level.

Edit: Updated my reply.
Regards,

1 Like

also, eyeoffset if pixeloffset doesn’t work for you.