Graphic features

The viewer's graphic object allows us to add custom graphic elements to the map.

Pressing the button below will take some random points inside the current bounds,
create a polygon, and put the graphic feature to the map.

The code:

// create polygon geometry
geometry = new giscloud.geometry.Polygon([new giscloud.geometry.Line(points)]);

// create a style
style = new giscloud.GraphicStyle("polygon");
style.color = giscloud.Color.randomHue(100, 60);

// create the graphic feature
polygonGraphic = new giscloud.GraphicFeature(geometry, style);

// add the feature to the map
viewer.graphic.add(polygonGraphic);