Graphic Class

  • Graphic
  • class Esri::ArcGISRuntime::Graphic

    A visual element displayed in a GraphicsOverlay. More...

    Header: #include <Graphic.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Object and Esri::ArcGISRuntime::GeoElement

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, Esri::ArcGISRuntime::Symbol *symbol, QObject *parent = nullptr)
    Graphic(const Esri::ArcGISRuntime::Geometry &geometry, Esri::ArcGISRuntime::Symbol *symbol, QObject *parent = nullptr)
    Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, QObject *parent = nullptr)
    Graphic(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr)
    Graphic(const QVariantMap &attributes, QObject *parent = nullptr)
    Graphic(QObject *parent = nullptr)
    virtual ~Graphic() override
    Esri::ArcGISRuntime::GraphicsOverlay *graphicsOverlay() const
    bool isSelected() const
    bool isVisible() const
    void setSelected(bool value)
    void setSymbol(Esri::ArcGISRuntime::Symbol *symbol)
    void setVisible(bool value)
    void setZIndex(int value)
    Esri::ArcGISRuntime::Symbol *symbol() const
    int zIndex() const
    bool operator==(Esri::ArcGISRuntime::Graphic *other) const

    Reimplemented Public Functions

    virtual Esri::ArcGISRuntime::AttributeListModel *attributes() const override
    virtual Esri::ArcGISRuntime::Geometry geometry() const override
    virtual void setGeometry(const Esri::ArcGISRuntime::Geometry &geometry) override

    Signals

    Detailed Description

    Graphics are displayed on the map through a graphics overlay. Common uses of graphics include providing input to a task, displaying output from a task, and marking a location based on user interaction with the map.

    Each graphic must contain a geometry describing the location and the shape of the graphic. The geometry preferably should be in the same spatial reference as the map, otherwise it will be reprojected on-the-fly (computationally expensive for a large number of graphics).

    A graphic can be associated with a symbol which determines how the graphic looks. Alternatively, the graphics overlay can be assigned a renderer which determines the appearance of all graphics in the overlay. If the graphic has an associated symbol, that symbol will override the renderer when displaying that graphic. The symbol used depends on the geometry type associated with the graphic. A MarkerSymbol is used for point and multipoint geometries, a LineSymbol for polyline geometries, and a FillSymbol for polygon geometries.

    A graphic can contain a list model of attributes (key-value pairs) providing more information about the graphic.

    Example:

    Create a graphic based on a point:

    Point point(-117, 34);
    SimpleMarkerSymbol* simpleMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::black), 12.0, this);
    QVariantMap attr;
    attr["region"] = "Southern California";
    Graphic* graphic = new Graphic(point, attr, simpleMarker, this);

    See also GraphicsOverlay.

    Member Function Documentation

    Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, Esri::ArcGISRuntime::Symbol *symbol, QObject *parent = nullptr)

    Constructor that takes a geometry, attributes, a symbol and an optional parent.

    The geometry and attributes can be null.

    Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, Esri::ArcGISRuntime::Symbol *symbol, QObject *parent = nullptr)

    Constructor that takes a geometry, a symbol and an optional parent.

    The geometry can be null.

    Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, QObject *parent = nullptr)

    Constructor that takes a geometry, attributes and an optional parent.

    The geometry and attributes can be null.

    Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr)

    Constructor that takes a geometry and an optional parent.

    The geometry can be null.

    Graphic::Graphic(const QVariantMap &attributes, QObject *parent = nullptr)

    Constructor that takes attributes and an optional parent.

    The attributes can be null.

    Graphic::Graphic(QObject *parent = nullptr)

    Default constructor that takes an optional parent.

    [signal] void Graphic::geometryChanged()

    Signal emitted when the geometry is changed.

    This function was introduced in Esri::ArcGISRuntime 100.2.1.

    See also GeoElement.

    [override virtual] Graphic::~Graphic()

    Destructor.

    [override virtual] Esri::ArcGISRuntime::AttributeListModel *Graphic::attributes() const

    Reimplements: GeoElement::attributes() const.

    Gets the attributes of the graphic as a list model of key-value pairs.

    [override virtual] Esri::ArcGISRuntime::Geometry Graphic::geometry() const

    Reimplements: GeoElement::geometry() const.

    Gets the geometry of this graphic.

    See also setGeometry().

    Esri::ArcGISRuntime::GraphicsOverlay *Graphic::graphicsOverlay() const

    Gets the graphics overlay containing this graphic, if any.

    bool Graphic::isSelected() const

    Gets whether the graphic is selected.

    Returns true if the graphic is selected.

    bool Graphic::isVisible() const

    Gets whether the graphic is visible.

    Returns true if the graphic is visible.

    [override virtual] void Graphic::setGeometry(const Esri::ArcGISRuntime::Geometry &geometry)

    Reimplements: GeoElement::setGeometry(const Esri::ArcGISRuntime::Geometry &geometry).

    Sets the geometry of the graphic to geometry.

    See also geometry().

    void Graphic::setSelected(bool value)

    Sets the graphic's selected state to value.

    See also isSelected().

    void Graphic::setSymbol(Esri::ArcGISRuntime::Symbol *symbol)

    Sets the symbol of the graphic to symbol.

    See also symbol().

    void Graphic::setVisible(bool value)

    Sets the graphic's visible state to value.

    See also isVisible().

    void Graphic::setZIndex(int value)

    Sets the z index of the graphic to value.

    Defines the draw order for graphics. 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. For dynamic 3D rendering (in a scene), graphic display order is determined by the distance to the camera rather than by Z-index. Z-index is considered, however, when using static rendering in a scene (draping graphics on the surface, in other words).

    If Z-index is not set, graphics will usually render in the order in which they were added to the graphics overlay, the first added is rendered first and subsequent ones on top. In rare cases, the rendering algorithm may change the display order to provide more efficient rendering. If ordering is important, set the Z-index explicitly on graphics. You can also place graphics of the same geometry type in their own graphics overlay and manage the order of the overlays in the MapView or SceneView.

    See also zIndex().

    Esri::ArcGISRuntime::Symbol *Graphic::symbol() const

    Gets the symbol of the graphic.

    See also setSymbol().

    int Graphic::zIndex() const

    Gets the z index of the graphic.

    See also setZIndex.

    bool Graphic::operator==(Esri::ArcGISRuntime::Graphic *other) const

    Equivalency operator.

    Graphics are only equal if they are the same instance. Different graphic instances with identical attributes will not compare equal.

    Returns true if this and other are the same graphic.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.