GraphicsOverlay Class

  • GraphicsOverlay
  • class Esri::ArcGISRuntime::GraphicsOverlay

    Manages a collection of graphics that can be displayed in a map view or scene view. More...

    Header: #include <GraphicsOverlay.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Object, Esri::ArcGISRuntime::PopupSource, and Esri::ArcGISRuntime::SnapSource

    Public Functions

    GraphicsOverlay(QObject *parent = nullptr)
    virtual ~GraphicsOverlay() override
    void clearSelection()
    Esri::ArcGISRuntime::Envelope extent() const
    Esri::ArcGISRuntime::FeatureReduction *featureReduction() const
    Esri::ArcGISRuntime::GraphicListModel *graphics() const
    bool isLabelsEnabled() const
    bool isScaleSymbols() const
    bool isVisible() const
    Esri::ArcGISRuntime::LabelDefinitionListModel *labelDefinitions() const
    double maxScale() const
    double minScale() const
    float opacity() const
    QString overlayId() const
    Esri::ArcGISRuntime::Renderer *renderer() const
    Esri::ArcGISRuntime::GraphicsRenderingMode renderingMode() const
    Esri::ArcGISRuntime::LayerSceneProperties sceneProperties() const
    void selectGraphics(const QList<Esri::ArcGISRuntime::Graphic *> &graphics)
    QList<Esri::ArcGISRuntime::Graphic *> selectedGraphics() const
    void setFeatureReduction(Esri::ArcGISRuntime::FeatureReduction *featureReduction)
    void setLabelsEnabled(bool labelsEnabled)
    void setMaxScale(double maxScale)
    void setMinScale(double minScale)
    void setOpacity(float opacity)
    void setOverlayId(const QString &overlayId)
    void setRenderer(Esri::ArcGISRuntime::Renderer *renderer)
    void setRenderingMode(Esri::ArcGISRuntime::GraphicsRenderingMode value)
    void setScaleSymbols(bool scaleSymbols)
    void setSceneProperties(const Esri::ArcGISRuntime::LayerSceneProperties &sceneProperties)
    void setVisible(bool visible)
    void unselectGraphics(const QList<Esri::ArcGISRuntime::Graphic *> &graphics)
    bool operator!=(const Esri::ArcGISRuntime::GraphicsOverlay &other) const
    bool operator==(const Esri::ArcGISRuntime::GraphicsOverlay &other) const

    Reimplemented Public Functions

    virtual bool isPopupEnabled() const override
    virtual Esri::ArcGISRuntime::PopupDefinition *popupDefinition() const override
    virtual void setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition) override
    virtual void setPopupEnabled(bool popupEnabled) override

    Detailed Description

    Graphics overlays displays a collection of graphics on top of all the layers (including reference layers) in a map view or scene view. Every map view or scene view can contain a collection of graphics overlays (GeoView::graphicsOverlays), and each graphics overlay can contain a collection of graphics (graphics). The graphics in the first GraphicsOverlay are drawn first, with subsequent graphics on top. The renderer defines the symbology of the graphics collection.

    A graphic's Graphic::zIndex value defines its draw order within the graphics overlay that contains it. The Graphic::zIndex value applies in a map view and a scene view if the scene view drapes the graphics on the surface (SurfacePlacement::DrapedFlat). In other scene view rendering, the graphic's display order is determined by the distance to the camera rather than by Z-index.

    If the Graphic::zIndex value is not set, graphics will 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 Graphic::zIndex explicitly on graphics.

    To improve view responsiveness, you can set the renderingMode to either of these options:

    Example:

    Create a graphics overlay and add a graphic to the overlay:

    // create graphics overlay
    GraphicsOverlay* graphicsOverlay = new GraphicsOverlay(this);
    
    // create a graphic
    Point point(0, 0);
    SimpleMarkerSymbol* simpleMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::X, QColor(Qt::red), 15.0, this);
    QVariantMap attr;
    attr["name"] = "Null Island";
    Graphic* graphic = new Graphic(point, attr, simpleMarker, this);
    
    //add the graphic to the graphics overlay
    graphicsOverlay->graphics()->append(graphic);

    See also Graphic, GraphicsOverlayListModel, and PopupSource.

    Member Function Documentation

    [explicit] GraphicsOverlay::GraphicsOverlay(QObject *parent = nullptr)

    Creates a graphics overlay object.

    • parent - The optional parent QObject.

    [override virtual] GraphicsOverlay::~GraphicsOverlay()

    Destructor

    void GraphicsOverlay::clearSelection()

    Deselects all graphics in the graphics overlay.

    Esri::ArcGISRuntime::Envelope GraphicsOverlay::extent() const

    Calculates and returns the extent of the graphics collection.

    The extent's SpatialReference is that of the GeoView that contains the overlay. If the overlay is not in a view, returns empty. If the overlay is in a view but that view does not yet have a spatial reference, returns empty. If the overlay is in a view with a spatial reference, but has no graphics, then an empty envelope will be returned.

    [since Esri::ArcGISRuntime 200.4] Esri::ArcGISRuntime::FeatureReduction *GraphicsOverlay::featureReduction() const

    Returns defines properties for dynamically aggregating and summarizing groups of graphics as the map scale and visible extent change. FeatureReduction is only supported for point graphics in dynamic rendering mode (GraphicsRenderingMode::Dynamic) in 2D. FeatureReduction is ignored and will result in the original point graphics being rendered for a GraphicsOverlay that: 1. Uses static rendering mode. 2. Is added to a SceneView. 3. Uses an unsupported renderer for the AggregationFeatureReduction::renderer. See AggregationFeatureReduction::renderer for more info.

    If this property is explicitly set to nullptr, FeatureReduction is removed from the GraphicsOverlay.

    This function was introduced in Esri::ArcGISRuntime 200.4.

    See also setFeatureReduction().

    Esri::ArcGISRuntime::GraphicListModel *GraphicsOverlay::graphics() const

    Returns the modifiable collection of graphics in this graphics overlay.

    You can add or remove graphics from this collection to modify what is displayed in the GeoView.

    If Z-index for graphics is not set, they 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 Graphic::zIndex 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 view.

    The graphics property is initially empty and can never be nullptr.

    [since Esri::ArcGISRuntime 100.1] bool GraphicsOverlay::isLabelsEnabled() const

    Returns true if labels are displayed for graphics in this graphics overlay, false otherwise.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    [override virtual] bool GraphicsOverlay::isPopupEnabled() const

    Reimplements: PopupSource::isPopupEnabled() const.

    Returns a flag indicating whether the PopupDefinition defined on the PopupSource is enable / disable.

    [since Esri::ArcGISRuntime 100.7] bool GraphicsOverlay::isScaleSymbols() const

    Returns true if the graphic overlay's symbols and labels honor the map reference scale when displayed in a map view, false otherwise.

    If the map has a positive reference scale, and the overlay honors it, then symbols and labels will be drawn at their specified size when the viewing scale is the same as the reference scale. They will grow or shrink as the view zooms in or out to keep the symbol a fixed size on the map. If the map has no reference scale, the reference scale is zero, or isScaleSymbols is false, the symbols and labels will be drawn at their fixed screen size.

    isScaleSymbols only affects display in a MapView. The symbols and labels will be displayed at fixed screen size in a SceneView.

    The default value is false.

    This function was introduced in Esri::ArcGISRuntime 100.7.

    bool GraphicsOverlay::isVisible() const

    Returns true if the graphics overlay is visible, false otherwise.

    [since Esri::ArcGISRuntime 100.1] Esri::ArcGISRuntime::LabelDefinitionListModel *GraphicsOverlay::labelDefinitions() const

    Returns the modifiable collection of LabelDefinition objects for this graphics overlay.

    A LabelDefinition defines the text, appearance, and position of labels for the graphics. You can manage graphic labeling by defining new LabelDefinition objects and adding or removing them from this collection.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    double GraphicsOverlay::maxScale() const

    Returns the maximum scale at which to display the graphics overlay. A small number allows the map to display the layer when zooming further in.

    This controls the maximum scale at which the graphics overlay is displayed. If the current map scale is smaller than the maximum scale, then this graphics overlay will not be displayed.

    A scale is usually referred to as 1:X, where X is the scale specified here. This value is the relative scale to the real world, where one inch on the screen is X inches in the real world. Note that this is only an approximation and is dependent on the map's projection that can add some distortion, as well as the system's reported DPI setting which doesn't necessarily match the actual DPI of the screen.

    The default value of this property is NaN which makes the layer unbounded by any scale.

    See also setMaxScale().

    double GraphicsOverlay::minScale() const

    Returns the minimum scale at which to display the graphics overlay. A large number allows the map to display the layer when zooming further out.

    This controls the minimum scale at which the graphics overlay is displayed. If the current map scale is larger than the minimum scale, then this graphics overlay will not be displayed.

    A scale is usually referred to as 1:X, where X is the scale specified here. This value is the relative scale to the real world, where one inch on the screen is X inches in the real world. Note that this is only an approximation and is dependent on the map's projection that can add some distortion, as well as the system's reported DPI setting which doesn't necessarily match the actual DPI of the screen.

    The default value of this property is NaN which makes the layer unbounded by any scale.

    See also setMinScale().

    float GraphicsOverlay::opacity() const

    Returns the opacity for the graphics overlay.

    Must be a value between 0 and 1 with 1 being solid or opaque and 0 being transparent. The default opacity is 1.

    See also setOpacity().

    [since Esri::ArcGISRuntime 100.2] QString GraphicsOverlay::overlayId() const

    Returns a string that identifies the graphics overlay in the GeoView::graphicsOverlays collection.

    You can give a graphics overlay an ID. If the collection of graphics overlays in a GeoView contains several graphics overlays, you can use the ID to find the one you need.

    The default value of id is an empty string. A graphics overlay's id does not need to be unique.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    See also setOverlayId().

    [override virtual] Esri::ArcGISRuntime::PopupDefinition *GraphicsOverlay::popupDefinition() const

    Reimplements: PopupSource::popupDefinition() const.

    Returns the pop-up definition.

    The PopupDefinition associated with the popup source. A nullptr if an error occurs or if the popup source is not associated with a pop-up definition.

    See also setPopupDefinition().

    Esri::ArcGISRuntime::Renderer *GraphicsOverlay::renderer() const

    Defines how graphics in the overlay are symbolized when displayed.

    Symbols set on the individual graphics will override the renderer.

    See also setRenderer().

    Esri::ArcGISRuntime::GraphicsRenderingMode GraphicsOverlay::renderingMode() const

    Returns the rendering mode used to display graphics in the overlay.

    For more efficient rendering of large numbers of graphics, set the rendering mode to GraphicsRenderingMode::Static. In order to ensure map responsiveness, static rendering does not refresh the display while pan and zoom operations are in progress. The amount of graphics an overlay can handle in this mode is mainly limited by the system memory.

    See also setRenderingMode().

    Esri::ArcGISRuntime::LayerSceneProperties GraphicsOverlay::sceneProperties() const

    Returns the scene properties for the graphics overlay.

    Use scene properties to control how graphics are displayed in a SceneView. For example, you can adjust the LayerSceneProperties::altitudeOffset or the LayerSceneProperties::surfacePlacement in the SceneView.

    None of these settings are applied if the graphics overlay is added to a MapView.

    See also setSceneProperties().

    [since Esri::ArcGISRuntime 100.2] void GraphicsOverlay::selectGraphics(const QList<Esri::ArcGISRuntime::Graphic *> &graphics)

    Selects the specified graphics.

    • graphics - The graphics to be selected.

    Any graphics that are not in the overlay will be ignored.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    QList<Esri::ArcGISRuntime::Graphic *> GraphicsOverlay::selectedGraphics() const

    Returns a collection of all the selected graphics in the graphics overlay.

    [since Esri::ArcGISRuntime 200.4] void GraphicsOverlay::setFeatureReduction(Esri::ArcGISRuntime::FeatureReduction *featureReduction)

    Sets the featureReduction to featureReduction.

    This function was introduced in Esri::ArcGISRuntime 200.4.

    See also featureReduction.

    void GraphicsOverlay::setLabelsEnabled(bool labelsEnabled)

    Sets whether labels are enabled on graphics in this overlay to labelsEnabled.

    See also isLabelsEnabled.

    void GraphicsOverlay::setMaxScale(double maxScale)

    Sets the maximum scale at which the graphics should be displayed to maxScale.

    See also maxScale.

    void GraphicsOverlay::setMinScale(double minScale)

    Sets the minimum scale at which the graphics should be displayed to minScale.

    See also minScale.

    void GraphicsOverlay::setOpacity(float opacity)

    Sets the opacity to opacity.

    See also opacity.

    [since Esri::ArcGISRuntime 100.2] void GraphicsOverlay::setOverlayId(const QString &overlayId)

    Sets the graphics overlay's ID to overlayId.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    See also overlayId().

    [override virtual] void GraphicsOverlay::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition)

    Reimplements: PopupSource::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition).

    Sets the popup definition to popupDefinition.

    See also popupDefinition.

    [override virtual] void GraphicsOverlay::setPopupEnabled(bool popupEnabled)

    Reimplements: PopupSource::setPopupEnabled(bool popupEnabled).

    Sets whether the PopupSource is enabled to popupEnabled.

    See also isPopupEnabled.

    void GraphicsOverlay::setRenderer(Esri::ArcGISRuntime::Renderer *renderer)

    Sets the renderer of the overlay to renderer.

    See also renderer.

    void GraphicsOverlay::setRenderingMode(Esri::ArcGISRuntime::GraphicsRenderingMode value)

    Sets the GraphicsRenderingMode of the overlay to value.

    See also renderingMode.

    [since Esri::ArcGISRuntime 100.7] void GraphicsOverlay::setScaleSymbols(bool scaleSymbols)

    Sets the scaleSymbols to scaleSymbols.

    This function was introduced in Esri::ArcGISRuntime 100.7.

    See also isScaleSymbols.

    void GraphicsOverlay::setSceneProperties(const Esri::ArcGISRuntime::LayerSceneProperties &sceneProperties)

    Sets the LayerSceneProperties of the overlay to sceneProperties.

    See also sceneProperties.

    void GraphicsOverlay::setVisible(bool visible)

    Sets the graphics overlay visibility to visible.

    See also isVisible.

    [since Esri::ArcGISRuntime 100.2] void GraphicsOverlay::unselectGraphics(const QList<Esri::ArcGISRuntime::Graphic *> &graphics)

    Unselects the specified graphics.

    • graphics - The graphics to be unselected.

    Any graphics that are not in the overlay will be ignored.

    This function was introduced in Esri::ArcGISRuntime 100.2.

    [since Esri::ArcGISRuntime 200.2] bool GraphicsOverlay::operator!=(const Esri::ArcGISRuntime::GraphicsOverlay &other) const

    Inequality operator. Returns true if this object and other are not equal.

    This function was introduced in Esri::ArcGISRuntime 200.2.

    See also GraphicsOverlay::operator==.

    bool GraphicsOverlay::operator==(const Esri::ArcGISRuntime::GraphicsOverlay &other) const

    Equivalency operator.

    Returns true if this object and other are equivalent.

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