Handling Billboards on click in BillboardCollection

Hi,

this is an old case, but the solution doesn’t work anymore

I thought I could handle this in the setInputHandler, like this

  const handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
    handler.setInputAction((click: any) => {
      // pick a feature
      const pickedFeature = this.viewer?.scene.pick(click.position);

      // specify your if-else-condition
      // const condition = 'URL OF SPECIFIC TILESET'

      .... 

    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
  }

and I would like to set a attribute description for my billboard, but the billboard looses this attribute.

Another possibility:
I draw a polyline (entity) from the middle of the billboard to ground, but this polyline isn’t selected

Regards

Rüdiger

and I would like to set a attribute description for my billboard, but the billboard looses this attribute

Are you sure it loses the attribute, or is the problem that it doesn’t get set? What is your code for setting and getting this attribute (it’s not in your code example above)? Also, do you mean property, or just get/set a given value on the entity?

Cheers,

Alex

Hi @Alexander_Johannesen ,

I use the following for the billboards:

dataSource.addBillboard({
        name: 'Point Object',
        description: mydescription,
        position: myposition,
        image: this.svgimage,
        horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
        verticalOrigin: Cesium.VerticalOrigin.CENTER,
        scale: 1,
        show: true, // default
      });

whereas the datasource is an extension of the Cesium.CustomDataSource and has a billboardCollecion for the handling of the billboards (according to @Gabby_Getz )

  addBillboard(myBillboard) {
	  
	  if (typeof this.mybillboardCollection === 'undefined') {
		  this.mybillboardCollection = new BillboardCollection();
		  
		  if (this._primitives) {
			  this._primitives.add(this.mybillboardCollection);
		  }
		  else
		  {
			  this.addPrimitives(this.mybillboardCollection);
		  }
	  }
	  
	  if (this.mybillboardCollection.length < this.numberBillboards)
	  {
		  this.mybillboardCollection.add(myBillboard);
		  // this.setBillboardTextureAtlasDimension(myBillboard.imagewidth, myBillboard.imageheight);
	  }
	  else
	  {
		  this.mybillboardCollection = new BillboardCollection();
		
		  
		  this.mybillboardCollection.add(myBillboard);
		  
		  this._primitives.add(this.mybillboardCollection);
	  }
  }

numberBillboards depends on the hardware/gl_textureSize

I know that the billboards have no attribute/property description, but I thought that a private attribute “description” will remain.

In the clicHandler I receive the primitive but I have no access to an attribute description.

image

Regards

Rüdiger

Hmm, I think your problem is that “description” isn’t a property of a Billboard. Are you describing something that used to work but now didn’t, or something else?

For properties like this we usually use an Entity’s property API (get/set), however with primitives, I guess you can sorta hack one in there, so just before you actually add it, create it as a referenced object before adding it, so instead of just;

this.mybillboardCollection.add(myBillboard);

add in;

let b = this.mybillboardCollection.add(myBillboard);
if ( myBillboard.description ) {
   b.description = myBillboard.description;
}

… or add in here the equivalent property API (ie. b.addProperty(…) )

Cheers,

Alex

Hi @Alexander_Johannesen,

my description should work - but didn’t. But your trick/hack with

let b = this.mybillboardCollection.add(myBillboard);
if ( myBillboard.description ) {
   b.description = myBillboard.description;
}

works - great !!

Now I have one more question - with this description I would like to open the “Standard-” InfoBox.
Can I open the infoBox programmatically in the setInputAction ?

Do you have another trick !

Rüdiger

Hiya,

my description should work

Hmm, I’m not so sure, and certainly not according to the documentation. Why do you think it should work?

As to the widget stuff, I don’t use those at all so can’t help you there. Anyone else?

Cheers,

Alex

Hi,

I thought, that the object (with all his attribute/properties) given to the add function will preserve, but that doesn’t work - so to use the object which is the return value would do the trick !

Rüdiger

The thing is that “description” (when you pass this into the add() function) isn’t part of the schema. If you look at BillboardCollection - Cesium Documentation you’ll see the parameters it recognizes. Anything else, like “description”, is just a dynamic property you specify, so these should be handled through the Property API, depending on your need for serialising, etc.

Cheers,

Alex

Hi, is it possible to add some functions to the billboard? because when you click on the billboard it takes you to the location, can i add some features?