Skip To Content

Create a graphics layer

In this topic

Graphics layers allow you to dynamically display graphics on a map. A graphics layer contains one or more graphic features. It could, for example, be used to hold polygons or lines drawn by a user or display features that satisfy the results of a task such as query or geoprocessing.

Add a graphics layer

The graphics layer contains graphics that are displayed on the map. To create a graphic to add to a graphic layer, do the following:

  • Create a symbol that defines how the graphic will be presented.
  • Create a geometry that represents where the graphic will be displayed.
  • Create a graphic that uses the defined symbol and geometry. This is the item that is added to the graphics layer.

The following code shows how to add a graphic to a graphics layer and a graphics layer to an existing map:

//define your point, line or polygon and symbol
EsriRuntimeQt::Point point1(1500000, 7500000, m_map->spatialReference());
EsriRuntimeQt::SimpleMarkerSymbol redCircle(Qt::red,8,
           EsriRuntimeQt::SimpleMarkerSymbolStyle::Circle);
EsriRuntimeQt::Graphic* graphic1 = new EsriRuntimeQt::Graphic(point1, redCircle);

//add the graphic to the layer and the layer to the map
m_graphicsLayer->addGraphic(graphic1);
m_map->addLayer(m_graphicsLayer);