A type of GeoElement that has a shape (geometry), symbol, and attributes and can be displayed in a map view or scene view. More...
Header: | #include <Graphic.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::Object and Esri::ArcGISRuntime::GeoElement |
Public Functions
Graphic(QObject *parent = nullptr) | |
Graphic(const QVariantMap &attributes, QObject *parent = nullptr) | |
Graphic(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr) | |
Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, 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, Esri::ArcGISRuntime::Symbol *symbol, 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 |
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
void | geometryChanged() |
Detailed Description
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 SpatialReference as the map view or scene view to which it is added. If the geometry has a different 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 Symbol that defines the graphic's appearance. Alternatively, the GraphicsOverlay can be assigned a 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 MarkerSymbol is used for Point and Multipoint geometries, a SimpleLineSymbol for Polyline geometries, and a SimpleFillSymbol for Polygon or Envelope geometries.
You can select or deselect graphics (isSelected), change the visibility of a graphic (isVisible), and manage the order in which they are displayed (zIndex).
Each graphic can have a collection of attributes (as key-value pairs) to provide more information.
Example:
Create a graphic based on a point:
Point point(-117, 34); auto* simpleMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::black), 12.0, this); QVariantMap attr; attr["region"] = "Southern California"; auto* graphic = new Graphic(point, attr, simpleMarker, this);
Relevant samples:
- Add graphics with renderer: A renderer allows you to change the style of all graphics in a graphics overlay by referencing a single symbol style.
- Add graphics with symbols: Use a symbol style to display a graphic on a graphics overlay.
- Animate 3D symbols: Demonstrates how to animate a graphic's position and rotation and follow it using a `OrbitGeoElementCameraController`.
- Clip geometry: Clip a geometry with another geometry.
- Create and edit geometries: Use the Geometry Editor to create new point, multipoint, polyline, or polygon geometries or to edit existing geometries by interacting with a map view.
- Create and save KML file: Construct a KML document and save it as a KMZ file.
- Create geometries: Create simple geometry types.
- Display content of utility network container: A utility network container allows a dense collection of features to be represented by a single feature, which can be used to reduce map clutter.
- Display utility associations: Create graphics for utility associations in a utility network.
- Distance composite symbol: Change a graphic's symbol based on the camera's proximity to it.
- Find address: Find the location for an address.
- Find closest facility to an incident (interactive): Find a route to the closest facility from a location.
- Find closest facility to multiple incidents (service): Find routes from several locations to the respective closest facility.
- Find service areas for multiple facilities: Find the service areas of several facilities from a feature service.
- Geodesic operations: Calculate a geodesic path between two points and measure its distance.
- Graphics overlay (dictionary renderer): This sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.
- Identify graphics: Display an alert message when a graphic is clicked.
- Perform valve isolation trace: Run a filtered trace to locate operable features that will isolate an area from the flow of network resources.
- Picture marker symbol: Use pictures for markers.
- Scene symbols: Show various kinds of 3D symbols in a scene.
- Set surface placement mode: Position graphics relative to a surface using different surface placement modes.
- Simple marker symbol: Show a simple marker symbol on a map.
- Simple renderer: Display common symbols for all graphics in a graphics overlay with a renderer.
- Sketch on map: This sample demonstrates how to use the Sketch Editor to edit or sketch a new point, line, or polygon geometry on to a map.
- Spatial operations: Find the union, intersection, or difference of two geometries.
- Spatial relationships: Determine spatial relationships between two geometries.
- Trace utility network: Discover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
- Viewshed (Geoprocessing): Calculate a viewshed using a geoprocessing service, in this case showing which parts of a landscape are visible from points on mountainous terrain.
See also GraphicsOverlay.
Member Function Documentation
[explicit]
Graphic::Graphic(QObject *parent = nullptr)
Creates a graphic with a empty geometry and symbol.
- parent - The optional parent QObject.
[explicit]
Graphic::Graphic(const QVariantMap &attributes, QObject *parent = nullptr)
Creates a graphic with the given attributes.
- attributes - The attributes of the graphic. Can be empty.
- parent - The optional parent QObject.
[explicit]
Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr)
Creates a graphic with the given geometry.
- geometry - geometry. Can be empty.
- parent - The optional parent QObject.
Graphic::Graphic(const Esri::ArcGISRuntime::Geometry &geometry, const QVariantMap &attributes, QObject *parent = nullptr)
Creates a graphic with the given geometry and attributes.
- geometry - geometry. Can be empty.
- attributes - The attributes of the graphic. Can be empty.
- parent - The optional parent QObject.
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, Esri::ArcGISRuntime::Symbol *symbol, QObject *parent = nullptr)
Creates a graphic with the given geometry, attributes, and symbol.
- geometry - geometry. Can be empty.
- attributes - The attributes of the graphic. Can be empty.
- symbol - symbol. Can be
nullptr
. - parent - The optional parent QObject.
[override virtual]
Graphic::~Graphic()
Destructor.
[override virtual]
Esri::ArcGISRuntime::AttributeListModel *Graphic::attributes() const
Reimplements: GeoElement::attributes() const.
Gets the attributes of the GeoElement as a collection of name/value pairs.
[override virtual]
Esri::ArcGISRuntime::Geometry Graphic::geometry() const
Reimplements: GeoElement::geometry() const.
Returns the geometry that defines the shape and location of the GeoElement.
See also setGeometry().
[signal, since Esri::ArcGISRuntime 100.2.1]
void Graphic::geometryChanged ()
Signal emitted when the geometry is changed.
This function was introduced in Esri::ArcGISRuntime 100.2.1.
See also GeoElement.
Esri::ArcGISRuntime::GraphicsOverlay *Graphic::graphicsOverlay () const
Returns the graphics overlay the graphic is contained in. If the graphic is not contained in an overlay then nullptr
is returned.
bool Graphic::isSelected () const
Returns true
if the graphic is selected, false
otherwise.
bool Graphic::isVisible () const
Returns true
if the graphic is visible, false
otherwise.
[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 zIndex to value.
See also zIndex.
Esri::ArcGISRuntime::Symbol *Graphic::symbol() const
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 Symbol or be added to a graphics overlay that has a renderer assigned. A 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 SimpleMarkerSymbol, SimpleLineSymbol, and SimpleFillSymbol. The symbol type must match the GeometryType of the graphic. For example, a FillSymbol is used with graphics that are based on polygon geometry. The rendering of a graphic's symbol takes precedence over the Renderer that may be set on the GraphicsOverlay.
See also setSymbol().
int Graphic::zIndex () const
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).
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 setZIndex().
[since Esri::ArcGISRuntime 200.2]
bool Graphic::operator!=(Esri::ArcGISRuntime::Graphic *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 Graphic::operator==.
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.