placemark.setDescription equivalent in Cesium


What can be the equivalent method in Cesium as supposed to placemark.setDescription in Google Earth API? Label only renders single line as String. But what about multi-line comments/description about a location? Or is there a way to render html content in a placemark?


Hello Lokesh,

You can use the description property to have content appear in the InfoBox widget when you click the placemark. This can be plain text or html. Here is an example:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {timeline : false, animation : false});

var pinBuilder = new Cesium.PinBuilder();

var bluePin = viewer.entities.add({
name : ‘Blue pin’,
description: ‘

This is my pin

It’s color is royal blue’,
position : Cesium.Cartesian3.fromDegrees(-75.170726, 39.9208667),
billboard : {
image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM



The name property appears as the InfoBox panel header, and the description property can be seen in the panel body.



Hello Hannah,

Thank you for the reply. The solution seems legitimate but I am afraid that it doesn't work for my use case. My application doesn't have any user interaction and I need to show up some content when the camera zooms to the pin. Do you have any solution to this?


You can select the entity without clicking by setting the viewer.selectedEntity property.
For the example I posted above, add
viewer.selectedEntity = bluePin;


to the end of the code snippet.


Hello Hannah,

Your solution worked for me. Thank you.
Is there a way to deselect the entity as well once it has been selected?


Setting viewer.selectedEntity = undefined will deselect the entity =)


There you go. Worked perfectly!!
Thank you so much.