Graphic

A type of com.arcgismaps.mapping.GeoElement that has a shape (geometry), symbol, and attributes and can be displayed in a map view or scene view. Graphics are used to represent temporary data that exists for the lifetime of the application. For example, you can:

  • Show updated locations for objects in the map view, such as moving vehicles.

  • Display results from an analysis, geocoding, or routing operation.

  • Allow the user to draw temporary sketches on top of the map.

  • Store user input, such as a set of route stops to visit.

  • Show ad hoc text labels to describe things on the map.

To display a graphic, add it to a GraphicsOverlay.graphics collection and add the graphics overlay to your map view or scene view.

Each graphic has a geometry describing its location and shape. To maximize performance, the geometry should have the same com.arcgismaps.geometry.SpatialReference as the map view or scene view to which it is added. If the geometry has a different com.arcgismaps.geometry.SpatialReference, it will be reprojected on-the-fly. This can be computationally expensive when displaying a large number of graphics.

A graphic can have an associated com.arcgismaps.mapping.symbology.Symbol that defines the graphic's appearance. Alternatively, the GraphicsOverlay can be assigned a com.arcgismaps.mapping.symbology.Renderer that determines the appearance of all graphics in the overlay. If a graphic has an associated symbol, the symbol will override the overlay's renderer for the graphic's display. The symbol used depends on the geometry type associated with the graphic. A com.arcgismaps.mapping.symbology.MarkerSymbol is used for com.arcgismaps.geometry.Point and com.arcgismaps.geometry.Multipoint geometries, a com.arcgismaps.mapping.symbology.SimpleLineSymbol for com.arcgismaps.geometry.Polyline geometries, and a com.arcgismaps.mapping.symbology.SimpleFillSymbol for com.arcgismaps.geometry.Polygon or com.arcgismaps.geometry.Envelope geometries.

You can select or deselect graphics (Graphic.isSelected), change the visibility of a graphic (Graphic.isVisible), and manage the order in which they are displayed (Graphic.zIndex).

Each graphic can have a collection of attributes (as key-value pairs) to provide more information.

Since

200.1.0

Constructors

Link copied to clipboard
constructor(geometry: Geometry? = null, attributes: Map<String, Any?> = emptyMap(), symbol: Symbol? = null)

Creates a graphic with the given geometry, attributes, and symbol.

constructor(geometry: Geometry?, symbol: Symbol?)

Creates a graphic with the given geometry and symbol.

Properties

Link copied to clipboard
open override val attributes: MutableMap<String, Any?>

The attributes of the GeoElement as a collection of name/value pairs.

Link copied to clipboard
open override var geometry: Geometry?

The geometry defines the shape and location of the GeoElement.

Link copied to clipboard

The graphics overlay the graphic is contained in. If the graphic is not contained in an overlay then null is returned.

Link copied to clipboard

True if the graphic is selected, false otherwise.

Link copied to clipboard

True if the graphic is visible, false otherwise.

Link copied to clipboard

Defines the graphic's appearance when displayed in a map view or scene view. For graphics to appear in a map view or scene view, they must have a com.arcgismaps.mapping.symbology.Symbol or be added to a graphics overlay that has a renderer assigned. A com.arcgismaps.mapping.symbology.Symbol defines the properties used to display the graphic, such as color, outline, size, and style. There are many different types of symbols, such as com.arcgismaps.mapping.symbology.SimpleMarkerSymbol, com.arcgismaps.mapping.symbology.SimpleLineSymbol, and com.arcgismaps.mapping.symbology.SimpleFillSymbol. The symbol type must match the com.arcgismaps.geometry.GeometryType of the graphic. For example, a com.arcgismaps.mapping.symbology.FillSymbol is used with graphics that are based on polygon geometry. The rendering of a graphic's symbol takes precedence over the com.arcgismaps.mapping.symbology.Renderer that may be set on the GraphicsOverlay.

Link copied to clipboard
var zIndex: Int

Defines the draw order of a graphic. Graphics with higher Z-index values are drawn on top of lower Z-index graphics. A graphic's Z-index is mostly relevant for display in a two-dimensional map view. For dynamic 3D rendering (in a scene view), graphic display order is determined by the distance to the camera rather than by Z-index. The Z-index is considered, however, when using static rendering in a scene view (draping graphics on the surface, in other words).