Hello all, i am trying to develop a 3D web application in which i want to assign various property fields to each pin billboard entity . And i am not able to do that can anyone help me figuring this out .
var viewer = new Cesium.Viewer(‘cesiumContainer’, {timeline : false, animation : false});
var pinBuilder = new Cesium.PinBuilder();
var bluePin = viewer.entities.add({
name : ‘pole’,
position : Cesium.Cartesian3.fromDegrees(78.058097 , 30.338039 ,50.05),
billboard : {
image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}
});
i have used this code to add pin… now how can i add different fields and visualize them while clicking for popup .
Hi Ujjwal,
Here’s your sample with properties added to the entity.
var viewer = new Cesium.Viewer(‘cesiumContainer’, {timeline : false, animation : false});
``
var pinBuilder = new Cesium.PinBuilder();
// Create PropertyBag to hold our entity’s properties
var propertyBag = new Cesium.PropertyBag();
propertyBag.addProperty(‘MyProperty_A’, 0);
propertyBag.addProperty(‘MyProperty_B’, 1);
// Create an Entity
var bluePin = viewer.entities.add({
name : 'pole',
position : Cesium.Cartesian3.fromDegrees(78.058097 , 30.338039 ,50.05),
billboard : {
image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
}**,**
properties: propertyBag
});
The only way to have information displayed in the Viewer’s information box is via the entity’s description. Anything beyond that would be a requirement on the app you’re developing. There’s more information about using HTML in the description in this forum topic.
Hope that helps.
Scott
thank you so much sir for your response… but unfortunately this code is not working either , it is not displaying assigned properties yet … what should i do now.
The Viewer widget’s default double-click behavior is to display the entity’s description in the InfoBox. Here’s how I chose to present the properties in my example (around line 1625 in Viewer.js).
if (showSelection) {
infoBoxViewModel.titleText = defaultValue(selectedEntity.name, selectedEntity.id);
if (selectedEntity.properties) {
var description = ‘’;
var entityPropertyNames = selectedEntity.properties.propertyNames;
var entityValues = selectedEntity.properties.getValue(time);
for (var p = 0; p < entityPropertyNames.length; p++) {
description += ‘’ + entityPropertyNames[p] + ’ = ’ + JSON.stringify(entityValues[entityPropertyNames[p]], null, 2) + ‘
\n’;
}
infoBoxViewModel.description = description;
} else {
infoBoxViewModel.description = Property.getValueOrDefault(selectedEntity.description, time, ‘’);
}
} else {
infoBoxViewModel.titleText = '';
infoBoxViewModel.description = '';
}
``
got it… thank you so much Scott Reynolds sir for your attention and effort.