assigning various properties to an entity pin billboard

1,106 views
Skip to first unread message

Ujjwal yadav

unread,
Apr 3, 2018, 6:06:17 AM4/3/18
to cesium-dev
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 .

Scott Reynolds

unread,
Apr 4, 2018, 8:28:38 AM4/4/18
to cesium-dev
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

Ujjwal yadav

unread,
Apr 5, 2018, 2:55:48 AM4/5/18
to cesiu...@googlegroups.com
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.
 

--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/Vby0gOs7gEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Scott Reynolds

unread,
Apr 6, 2018, 9:04:02 AM4/6/18
to cesium-dev
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 += '<p>' + entityPropertyNames[p] + ' = ' + JSON.stringify(entityValues[entityPropertyNames[p]], null, 2) + '<p>\n';
                    }
                    infoBoxViewModel.description = description;
                } else {
                    infoBoxViewModel.description = Property.getValueOrDefault(selectedEntity.description, time, '');
                }
            } else {
                infoBoxViewModel.titleText = '';
                infoBoxViewModel.description = '';
            }

To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.

Ujjwal yadav

unread,
Apr 10, 2018, 2:06:37 AM4/10/18
to cesiu...@googlegroups.com
got it.. thank you so much Scott Reynolds sir for your attention and effort.

To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages