Click or drag to resize

Graphic Class

Instances of this class represent graphics. Graphics can be displayed on the map through a GraphicsOverlay. Graphics can be used as input to a task, or they can be used to display output from a task, or in response to user interaction.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.UI
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.9.0
public class Graphic : GeoElement, INotifyPropertyChanged

The Graphic type exposes the following members.

Public methodCode exampleGraphic
Initializes a new instance of the Graphic class
Public methodGraphic(IEnumerableKeyValuePairString, Object)
Initializes a new instance of the Graphic class and setting the attributes.
Public methodCode exampleGraphic(Geometry)
Initializes a new instance of the Graphic class and setting the geometry.
Public methodCode exampleGraphic(Geometry, Symbol)
Initializes a new instance of the Graphic class and setting the geometry and symbol.
Public methodGraphic(Geometry, IEnumerableKeyValuePairString, Object)
Initializes a new instance of the Graphic class and setting the geometry.
Public methodGraphic(Geometry, IEnumerableKeyValuePairString, Object, Symbol)
Initializes a new instance of the Graphic class and setting the geometry, attributes and symbol.
Public propertyCode exampleAttributes
Gets the attributes of this GeoElement as a collection of name/value pairs.
(Inherited from GeoElement.)
Public propertyGeometry
Gets or sets the Geometry of the graphic.
(Overrides GeoElementGeometry.)
Public propertyGraphicsOverlay
Gets the GraphicsOverlay that this table is attached to
Public propertyCode exampleIsSelected
Gets or sets whether this graphic is selected.
Public propertyIsVisible
Gets or sets whether this graphic is rendered on a map.
Public propertyCode exampleSymbol
Gets or sets the symbol for the graphic.
Public propertyCode exampleZIndex
Gets or sets the draw order for graphics. Graphics with higher Z-index values are drawn on top of lower Z-index graphics.

Each graphic must contain an Geometry describing the location and the shape of the graphic.

A graphic can be associated with an Symbol which determines how the graphic looks. Alternatively, the graphics layer can be assigned an Renderer which determines the appearance of all graphics in the layer. Note, symbols associated with individual graphics take precedence over the symbols chosen by the renderer. The symbol used depends upon the geometry type associated with the graphic. A MarkerSymbol is used for MapPoint and Multipoint geometries, SimpleLineSymbol for Polyline geometries, and SimpleFillSymbol for Polygon geometries.

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



Example Name: ConvexHullList

Generate convex hull polygon(s) from multiple input geometries.

Code example screen shot.

// Copyright 2018 Esri.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System.Collections.Generic;
using System.Drawing;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.ConvexHullList
        name: "Convex hull list",
        category: "Geometry",
        description: "Generate convex hull polygon(s) from multiple input geometries.",
        instructions: "Click the 'Create Convex Hull' button to create convex hull(s) from the polygon graphics. If the 'Union' checkbox is checked, the resulting output will be one polygon being the convex hull for the two input polygons. If the 'Union' checkbox is un-checked, the resulting output will have two convex hull polygons - one for each of the two input polygons. Click the 'Reset' button to start over.",
        tags: new[] { "analysis", "geometry", "outline", "perimeter", "union" })]
    public partial class ConvexHullList
        // Graphics overlay to display the graphics.
        private GraphicsOverlay _graphicsOverlay;

        // Graphic that represents polygon1.
        private Graphic _polygonGraphic1;

        // Graphic that represents polygon2.
        private Graphic _polygonGraphic2;

        public ConvexHullList()


        private void Initialize()
            // Create a map with a topographic basemap.
            Map newMap = new Map(Basemap.CreateTopographic());

            // Assign the map to the MapView.
            MyMapView.Map = newMap;

            // Create a graphics overlay to hold the various graphics.
            _graphicsOverlay = new GraphicsOverlay();

            // Add the created graphics overlay to the MapView.

            // Create a simple line symbol for the outline for the two input polygon graphics.
            SimpleLineSymbol polygonsSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Blue, 4);

            // Create the color that will be used for the fill of the two input polygon graphics. It will be a
            // semi -transparent, blue color.
            Color polygonsFillColor = Color.FromArgb(34, 0, 0, 255);

            // Create the simple fill symbol for the two input polygon graphics - comprised of a fill style, fill
            // color and outline.
            SimpleFillSymbol polygonsSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, polygonsFillColor,

            // Create the graphic for polygon1 - comprised of a polygon shape and fill symbol.
            _polygonGraphic1 = new Graphic(CreatePolygon1(), polygonsSimpleFillSymbol)

                // Set the Z index for the polygon1 graphic so that it appears above the convex hull graphic(s) added later.
                ZIndex = 1

            // Add the polygon1 graphic to the graphics overlay collection.

            // Create the graphic for polygon2 - comprised of a polygon shape and fill symbol.
            _polygonGraphic2 = new Graphic(CreatePolygon2(), polygonsSimpleFillSymbol)

                // Set the Z index for the polygon2 graphic so that it appears above the convex hull graphic(s) added later.
                ZIndex = 1

            // Add the polygon2 graphic to the graphics overlay collection.

        private Polygon CreatePolygon1()
            // Create a point collection that represents polygon1. Use the same spatial reference as the underlying base map.
            PointCollection pointCollection1 = new PointCollection(SpatialReferences.WebMercator)
                // Add all of the polygon1 boundary map points to the point collection.
                new MapPoint(-4983189.15470412, 8679428.55774286),
                new MapPoint(-5222621.66664186, 5147799.00666126),
                new MapPoint(-13483043.3284937, 4728792.11077023),
                new MapPoint(-13273539.8805482, 2244679.79941622),
                new MapPoint(-5372266.98660294, 2035176.3514707),
                new MapPoint(-5432125.11458738, -4100281.76693377),
                new MapPoint(-2469147.7793579, -4160139.89491821),
                new MapPoint(-1900495.56350578, 2035176.3514707),
                new MapPoint(2768438.41928007, 1975318.22348627),
                new MapPoint(2409289.65137346, 5477018.71057565),
                new MapPoint(-2409289.65137346, 5387231.518599),
                new MapPoint(-2469147.7793579, 8709357.62173508)
            // Create a polyline geometry from the point collection.
            Polygon polygon1 = new Polygon(pointCollection1);

            // Return the polygon.
            return polygon1;

        private Polygon CreatePolygon2()
            // Create a point collection that represents polygon2. Use the same spatial reference as the underlying base map.
            PointCollection pointCollection2 = new PointCollection(SpatialReferences.WebMercator)
                // Add all of the polygon2 boundary map points to the point collection.
                new MapPoint(5993520.19456882, -1063938.49607736),
                new MapPoint(3085421.63862418, -1383120.04490055),
                new MapPoint(3794713.96934239, -2979027.78901651),
                new MapPoint(6880135.60796657, -4078430.90162972),
                new MapPoint(7092923.30718203, -2837169.32287287),
                new MapPoint(8617901.81822617, -2092412.37561875),
                new MapPoint(6986529.4575743, 354646.16535905),
                new MapPoint(5319692.48038653, 1205796.96222089)
            // Create a polyline geometry from the point collection.
            Polygon polygon2 = new Polygon(pointCollection2);

            // Return the polygon.
            return polygon2;

        private void ConvexHullListButton_Click(object sender, RoutedEventArgs e)
                // Get the boolean value whether to create a single convex hull (true) or independent convex hulls (false).
                bool unionBool = (bool)ConvexHullListCheckBox.IsChecked;

                // Add the geometries of the two polygon graphics to a list of geometries. It will be used as the 1st
                // input parameter of the GeometryEngine.ConvexHull function.
                List<Geometry> inputListOfGeomtries = new List<Geometry>

                // Get the returned result from the convex hull operation. When unionBool = true there will be one returned
                // polygon, when unionBool = false there will be one convex hull returned per input geometry.
                IEnumerable<Geometry> convexHullGeometries = GeometryEngine.ConvexHull(inputListOfGeomtries, unionBool);

                // Loop through the returned geometries.
                foreach (Geometry oneGeometry in convexHullGeometries)
                    // Create a simple line symbol for the outline of the convex hull graphic(s).
                    SimpleLineSymbol convexHullSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 10);

                    // Create the simple fill symbol for the convex hull graphic(s) - comprised of a fill style, fill
                    // color and outline. It will be a hollow (i.e.. see-through) polygon graphic with a thick red outline.
                    SimpleFillSymbol convexHullSimpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, Color.Red,

                    // Create the graphic for the convex hull(s) - comprised of a polygon shape and fill symbol.
                    Graphic convexHullGraphic = new Graphic(oneGeometry, convexHullSimpleFillSymbol)
                        // Set the Z index for the convex hull graphic(s) so that they appear below the initial input graphics
                        // added earlier (polygon1 and polygon2).
                        ZIndex = 0

                    // Add the convex hull graphic to the graphics overlay collection.

                // Disable the button after has been used.
                ConvexHullListCheckBox.IsEnabled = false;
            catch (System.Exception ex)
                // Display an error message if there is a problem generating convex hull operation.
                MessageBox.Show(ex.Message, "Geometry Engine Failed!");

        private void ResetButton_Click(object sender, RoutedEventArgs e)
            // Clear all existing graphics.

            // Re-enable the button.
            ConvexHullListCheckBox.IsEnabled = true;

            // Add the polygons.
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
                    Content="Convex Hull" />
                    Content="Reset" />
                    IsChecked="True" />
See Also
Additional Examples
Hyperlink to ExampleDescription
AddGraphicsRendererA renderer allows you to change the style of all graphics in a graphics overlay by referencing a single symbol style.
AddGraphicsWithSymbolsUse a symbol style to display a graphic on a graphics overlay.
AnalyzeViewshedCalculate a viewshed using a geoprocessing service, in this case showing what parts of a landscape are visible from points on mountainous terrain.
Animate3DGraphicAn `OrbitGeoElementCameraController` follows a graphic while the graphic's position and rotation are animated.
BufferCreate a buffer around a map point and display the results as a `Graphic`
BufferListGenerate multiple individual buffers or a single unioned buffer around multiple points.
ChooseCameraControllerControl the behavior of the camera in a scene.
ClipGeometryClip a geometry with another geometry.
ClosestFacilityFind a route to the closest facility from a location.
ClosestFacilityStaticFind routes from several locations to the respective closest facility.
ConvexHullCreate a convex hull for a given set of points. The convex hull is a polygon with shortest perimeter that encloses a set of points. As a visual analogy, consider a set of points as nails in a board. The convex hull of the points would be like a rubber band stretched around the outermost nails.
ConvexHullListGenerate convex hull polygon(s) from multiple input geometries.
CreateGeometriesCreate simple geometry types.
CutGeometryCut a geometry along a polyline.
DensifyAndGeneralizeA multipart geometry can be densified by adding interpolated points at regular intervals. Generalizing multipart geometry simplifies it while preserving its general shape. Densifying a multipart geometry adds more vertices at regular intervals.
DictionaryRendererGraphicsOverlayThis sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.
DisplayUtilityAssociationsCreate graphics for utility associations in a utility network.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
FindAddressFind the location for an address.
FindPlaceFind places of interest near a location or within a specific area.
FindRouteDisplay directions for a route between two points.
FindServiceAreaFind the service area within a network from a given point.
FindServiceAreasForMultipleFacilitiesFind the service areas of several facilities from a feature service.
FormatCoordinatesFormat coordinates in a variety of common notations.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GenerateOfflineMapTake a web map offline.
GenerateOfflineMapWithOverridesTake a web map offline with additional options for each layer.
GeodesicOperationsCalculate a geodesic path between two points and measure its distance.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
IdentifyGraphicsDisplay an alert message when a graphic is clicked.
LineOfSightGeoElementShow a line of sight between two moving objects.
ListTransformationsGet a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.
MapImageLayerTablesFind features in a spatial table related to features in a non-spatial table.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.
MobileMapSearchAndRouteDisplay maps and use locators to enable search and routing offline using a Mobile Map Package.
NavigateRouteUse a routing service to navigate between points.
NavigateRouteReroutingNavigate between two points and dynamically recalculate an alternate route when the original route is unavailable.
NearestVertexFind the closest vertex and coordinate of a geometry to a point.
OfflineBasemapByReferenceUse the `OfflineMapTask` to take a web map offline, but instead of downloading an online basemap, use one which is already on the device.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
OfflineRoutingSolve a route on-the-fly using offline data.
PerformValveIsolationTraceRun a filtered trace to locate operable features that will isolate an area from the flow of network resources.
ProjectProject a point from one spatial reference to another.
RenderPictureMarkersUse pictures for markers.
RenderSimpleMarkersShow a simple marker symbol on a map.
ReverseGeocodeUse an online service to find the address for a tapped point.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.
ScenePropertiesExpressionsUpdate the orientation of a graphic using expressions based on its attributes.
SceneSymbolsShow various kinds of 3D symbols in a scene.
ShowLocationHistoryDisplay your location history on the map.
SimpleRenderersDisplay common symbols for all graphics in a graphics overlay with a renderer.
SketchOnMapUse the Sketch Editor to edit or sketch a new point, line, or polygon geometry on to a map.
SpatialOperationsFind the union, intersection, or difference of two geometries.
SpatialRelationshipsDetermine spatial relationships between two geometries.
SurfacePlacementsPosition graphics relative to a surface using different surface placement modes.
SymbolsFromMobileStyleCombine multiple symbols from a mobile style file into a single symbol.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
UseDistanceCompositeSymChange a graphic's symbol based on the camera's proximity to it.
ViewshedGeoElementAnalyze the viewshed for an object (GeoElement) in a scene.
ViewshedLocationPerform a viewshed analysis from a defined vantage point.