Hi,
Is it possible to use CallbackProperty on a label’s text?
Something like:
var labels = viewer.scene.primitives.add(new Cesium.LabelCollection());
labels.add({
position: position,
//this works
//text: “blah”,
//this doesn’t work
text : new Cesium.CallbackProperty(function() {
return “blah”;
}, false),
pixelOffset: new Cesium.Cartesian2(10, -10)
});
``
Thank you,
Fidel
Hi Fidel,
Callback properties only work for entities. This code should do what you need:
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : new Cesium.CallbackProperty(function() {
return “blah”;
}, false),
}
});
``
hope that helps,
Thanks Rachel, that looks promising but it seems to ignore my pixelOffset.
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : new Cesium.CallbackProperty(function() {
return “blah”;
}, false),
},
** pixelOffset****: new Cesium.Cartesian2(10, -10) //<----------- this line seems to be** ignored
});
``
Fidel, pixelOffset needs to be a property on the label object, you have it at the top level.
You guys are the best. Thank you very much