# Add Polyline to a GeometryInstance

Hello,

I’m trying to draw a geometry with adding different polygons and lines. When I try to draw only polygons I get it, but when I try to add lines to polygonsi have a “DeveloperError: options.geometry is required.” I think that it is a polyline geometry problem, but I don’t know how solve it. Here is a polyline part of my code:

var polygonInstances = ;
var scene = viewer.scene;
var primitives = scene.primitives;

polygonInstances.push(new Cesium.GeometryInstance({
geometry: Cesium.PolylineGeometry({
positions: Cesium.Cartesian3.fromDegreesArray([x0,y0,
x1,y1]),
material: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0. 0.0, 0.5))
})
}));

geometryInstances: polygonInstances,
appearance: new Cesium.PerInstanceColorAppearance({
closed: true,
translucent: false
})
}));

Does someone know what is my mistake? or what is the correct way to done it?

Thanks,

Aritz

There’s not really enough code here to be able to tell what the problem is. Can you post a complete Sandcastle example?

That being said, unless you have a specific need not addressed by the Entity API, I would suggest you use that instead. Check out this tutorial: http://cesiumjs.org/2015/02/02/Visualizing-Spatial-Data/

Hello Matthew,
I have a specific need, because I need to visualize some polygons and some multilinestring geometries which are in WKT format. I use a function to change WKT string values to a cartographic array values and save its in position array variable.

I solve my multilinestring geometries visualization problem with 2 different solutions:

OPTION1:
positions: positions,
material : new Cesium.Material.fromType(‘Color’, {
color : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
})
});

OPTION2:
name : name,
polyline : {
positions: positions,
material : new Cesium.Color(1.0, 0.0, 0.0, 1.0)
}
});

But now I see that the first option is slower when I interact with cesium interface. And second option has faster interactivity but has an entities pick function which I don’t need it.
¿How can I have the interactivity speed of the second one without the pick function?

Regards,

Aritz

While we don’t have a way to disable picking on individual entities yet (it will be added in the near future), you can disable it altogether when you create the viewer in your application. In the below code, selectionIndicator disables the “green box” widget that appears when you click an entity and infoBox disables the description widget that pops up on the side of the screen.

var viewer = new Cesium.Viewer(‘cesiumContainer’, {

infoBox : false,

selectionIndicator : false

});

Thank you Matthew!!

No works fine!! As I need.

Best Regards,

Aritz

I wanted say: “Now works fine!”