ma2s
ma2s

Reputation: 1312

How can I associate multiple rectangles to the entity in Cesiumjs?

In documentation I see entity seem's be able to have associated different shapes with it (point, polygon, polyline, rectangle, billboard etc.). But how can I add e.g multiple rectangles or polygons with different color, shape etc. ?

Upvotes: 1

Views: 1357

Answers (1)

emackey
emackey

Reputation: 12448

You need to create separate entities. A single entity has a lot of graphics options (point, label, polygon, etc) but only one of each per entity. So if you want three separate labels, you need three entities. They can all be in the same position if need be, with different label pixel offsets.

Updating my answer to include some "Primitive" code, in response to a comment below.

var rectangle = viewer.scene.primitives.add(new Cesium.RectanglePrimitive({
    rectangle : Cesium.Rectangle.fromDegrees(-120.0, 20.0, -60.0, 40.0)
}));

Upvotes: 1

Related Questions