Click or drag to resize

GraphicsOverlay Class

A collection of vector graphics for overlaying on the map
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.UI
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version:
public sealed class GraphicsOverlay : INotifyPropertyChanged, 

The GraphicsOverlay type exposes the following members.

Public methodCode exampleGraphicsOverlay
Initializes a new instance of the GraphicsOverlay class.
Public propertyCode exampleExtent
Gets the extent of the GraphicsOverlay.
Public propertyCode exampleGraphics
Gets the graphics collection.
Public propertyCode exampleId
Gets or sets an ID for the overlay
Public propertyIsPopupEnabled
Gets or sets a value indicating whether the PopupDefinition defined is enabled.
Public propertyIsVisible
Gets or sets the overlay visibility.
Public propertyLabelDefinitions
Gets a modifiable collection of label definitions for this graphics overlay.
Public propertyLabelsEnabled
Gets or sets a value indicating whether labels should be displayed for Graphics in this overlay.
Public propertyMaxScale
Gets or sets the maximum scale to display this layer at. A small number allows the map to display the layer when zooming further in.
Public propertyMinScale
Gets or sets the minimum scale to render this layer at. A large number allows the map to display the layer when zooming further out.
Public propertyOpacity
Gets or sets the opacity. Must be a value between 0 and 1.
Public propertyPopupDefinition
Gets or sets the pop-up definition for the graphics overlay.
Public propertyCode exampleRenderer
Gets or sets the renderer used for generating symbols.
Public propertyRenderingMode
Gets or sets a value indicating which rendering mode to use
Public propertyCode exampleSceneProperties
Gets or sets the scene properties for the graphics overlay.
Public propertySelectedGraphics
Gets the selected graphics.
Public propertySelectionColor Obsolete.
Gets or sets the color for selected graphics.
Public methodCode exampleClearSelection
Unselects all graphics in the layer
Protected methodFinalize
Finalizes an instance of the GraphicsOverlay class.
(Overrides ObjectFinalize.)
Public methodFromQueryResultJsonAsync Obsolete.
Deserializes the graphics from a JSON string containing the result of a query.
Public methodSelectGraphics
Selects the specified graphics.
Public methodUnselectGraphics
Unselects the specified graphics.
Public eventPropertyChanged
Occurs when a property value changes.


Example Name: AddGraphicsRenderer

This sample demonstrates how you add graphics and set a renderer on a graphic overlays.

Code example screen shot.

// Copyright 2016 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;
using System.Drawing;

namespace ArcGISRuntime.WPF.Samples.AddGraphicsRenderer
        "Add graphics (SimpleRenderer)",
        "This sample demonstrates how you add graphics and set a renderer on a graphic overlays.",
    public partial class AddGraphicsRenderer
        public AddGraphicsRenderer()

            // Create the UI, setup the control references and execute initialization 

        private void Initialize()
            // Create a map with 'Imagery with Labels' basemap and an initial location
            Map myMap = new Map(BasemapType.ImageryWithLabels, 34.056295, -117.195800, 14);

            // Create graphics when MapView's viewpoint is initialized
            MyMapView.ViewpointChanged += OnViewpointChanged;

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

        private void OnViewpointChanged(object sender, EventArgs e)
            // Unhook the event
            MyMapView.ViewpointChanged -= OnViewpointChanged;

            // Get area that is shown in a MapView
            Polygon visibleArea = MyMapView.VisibleArea;

            // Get extent of that area
            Envelope extent = visibleArea.Extent;

            // Get central point of the extent
            MapPoint centerPoint = extent.GetCenter();

            // Create values inside the visible extent for creating graphic
            double extentWidth = extent.Width / 5;
            double extentHeight = extent.Height / 10;

            // Create point collection
            Esri.ArcGISRuntime.Geometry.PointCollection points = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.WebMercator)
                    new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y - extentHeight * 2),
                    new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y + extentHeight * 2),
                    new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y + extentHeight * 2),
                    new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y - extentHeight * 2)

            // Create overlay to where graphics are shown
            GraphicsOverlay overlay = new GraphicsOverlay();

            // Add points to the graphics overlay
            foreach (MapPoint point in points)
                // Create new graphic and add it to the overlay
                overlay.Graphics.Add(new Graphic(point));

            // Create symbol for points
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol()
                Color = Color.Yellow,
                Size = 30,
                Style = SimpleMarkerSymbolStyle.Square

            // Create simple renderer with symbol
            SimpleRenderer renderer = new SimpleRenderer(pointSymbol);

            // Set renderer to graphics overlay
            overlay.Renderer = renderer;

            // Add created overlay to the MapView
<UserControl x:Class="ArcGISRuntime.WPF.Samples.AddGraphicsRenderer.AddGraphicsRenderer"
             d:DesignHeight="300" d:DesignWidth="300">
        <esri:MapView x:Name="MyMapView"/>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddGraphicsRendererThis sample demonstrates how you add graphics and set a renderer on a graphic overlays.
AddGraphicsWithSymbolsThis sample demonstrates how to add various types of graphics to a `GraphicsOverlay`.
AnalyzeViewshedThis sample demonstrates how to use GeoprocessingTask to calculate a viewshed using a geoprocessing service. Click any point on the map to see all areas that are visible within a 1 kilometer radius. It may take a few seconds for the model to run and send back the results.
Animate3DGraphicThis sample demonstrates how to animate a graphic's position and follow it using a camera controller.
BufferThis sample demonstrates how to use `GeometryEngine.Buffer` to create polygons from a map location and linear distance (radius). For each input location, the sample creates two buffer polygons (using the same distance) and displays them on the map using different symbols. One polygon is calculated using the `planar` (flat) coordinate space of the map's spatial reference. The other is created using a `geodesic` technique that considers the curved shape of the Earth's surface (which is generally a more accurate representation). Distortion in the map increases as you move away from the standard parallels of the spatial reference's projection. This map is in Web Mercator so areas near the equator are the most accurate. As you move the buffer location north or south from that line, you'll see a greater difference in the polygon size and shape. Planar operations are generally faster, but performance improvement may only be noticeable for large operations (buffering a great number or complex geometry). Creating buffers is a core concept in GIS proximity analysis, allowing you to visualize and locate geographic features contained within a polygon. For example, suppose you wanted to visualize areas of your city where alcohol sales are prohibited because they are within 500 meters of a school. The first step in this proximity analysis would be to generate 500 meter buffer polygons around all schools in the city. Any such businesses you find inside one of the resulting polygons are violating the law. If you are using planar buffers, make sure that the input locations and distance are suited to the spatial reference you're using. Remember that you can also create your buffers using geodesic and then project them to the spatial reference you need for display or analysis. For more information about using buffer analysis, see [How buffer analysis works]( in the ArcGIS Pro documentation.
BufferListThis sample demonstrates how to use a planar (Euclidean) buffer operation by calling `GeometryEngine.Buffer` to generate one or more polygons from a collection of input geometries and a corresponding collection of buffer distances. The result polygons can be returned as individual geometries or unioned into a single polygon output.
ClipGeometryThis sample demonstrates how to clip a geometry with an envelope using the GeometryEngine
ClosestFacilityDemonstrates how to solve a Closest Facility Task to find the closest route between a facility (hospital) and a incident (black cross).
ClosestFacilityStaticDemonstrates how to solve a Closest Facility Task to find the closest route between facilities and incidents.
ConvexHullThis sample demonstrates how to use the GeometryEngine.ConvexHull operation to generate a polygon that encloses a series of user-tapped map points.
ConvexHullListThis sample demonstrates how to use the GeometryEngine.ConvexHull to generate convex hull polygon(s) from multiple input geometries.
CreateGeometriesThis sample demonstrates simple ways to create different types of Geometry. The geometries are added as Graphics to a GraphicsOverlay and displayed in a MapView. An Envelope is used to set the Viewpoint of the MapView.
CutGeometryThis sample demonstrates how to cut a geometry with a polyline using the GeometryEngine.
DensifyAndGeneralizeThis sample demonstrates how to densify or generalize a polyline geometry. In this example, points representing a ship's location are shown at irregular intervals. You can densify the polyline to interpolate points along the line at regular intervals. Generalizing the polyline can also simplify the geometry while preserving its general shape.
EditAndSyncFeaturesThis sample demonstrates how to synchronize offline edits with a feature service.
ExportTilesThis sample demonstrates how to export tiles from a map server.
FindAddressThis sample demonstrates how you can use the LocatorTask API to geocode an address and display it with a pin on the map. Tapping the pin displays the reverse-geocoded address in a callout.
FindPlaceThis sample demonstrates how to use geocode functionality to search for points of interest, around a location or within an extent.
FindRouteThis sample demonstrates how to solve for the best route between two locations on the map and display driving directions between them.
FindServiceAreaDemonstrates how to find services areas around a point using the ServiceAreaTask. A service area shows locations that can be reached from a facility based off a certain impedance [travel time in this case]. Service areas for a two and five minute travel time are used. Barriers can also be added which can effect the service area by not letting traffic through and adding to the time to get to locations.
FormatCoordinatesThis sample demonstrates how to convert between `MapPoint` and string representations of a point using various coordinate systems.
GenerateGeodatabaseThis sample demonstrates how to take a feature service offline by generating a geodatabase.
GeodesicOperationsThis sample demonstrates how to use the Geometry engine to calculate a geodesic path between two points and measure its distance.
IdentifyGraphicsThis sample demonstrates how to identify graphics in a graphics overlay. When you tap on a graphic on the map, you will see an alert message displayed.
LineOfSightGeoElementThis sample demonstrates how to perform a dynamic line of sight analysis between two moving GeoElements.
ListTransformationsThis sample demonstrates how to use the TransformationCatalog to get a list of available DatumTransformations that can be used to project a Geometry between two different SpatialReferences, and how to use one of the transformations to perform the GeometryEngine.project operation. The TransformationCatalog is also used to set the location of files upon which grid-based transformations depend, and to find the default transformation used for the two SpatialReferences.
MapImageLayerTablesThis sample demonstrates how to get a non-spatial table from an ArcGIS map image layer. It shows how to query such a table, as well as how to find related features in another table. The non-spatial tables contained by a map service may contain additional information about sublayer features. Such information can be accessed by traversing table relationships defined in the service.
MapImageSublayerQueryThis sample demonstrates how to execute an attribute and spatial query on the sublayers of an ArcGIS map image layer. Sublayers of an ArcGISMapImageLayer may expose a ServiceFeatureTable through a Table property.This allows you to perform the same queries available when working with a table from a FeatureLayer: attribute query, spatial query, statistics query, query for related features, and so on.
NearestVertexThis sample demonstrates how to use the Geometry engine find the nearest vertex and nearest coordinate of a polygon to a point. The distance for each is shown.
RenderPictureMarkersThis sample demonstrates how to create picture marker symbols from a URL and embedded resources.
RenderSimpleMarkersThis sample adds a point graphic to a graphics overlay symbolized with a red circle specified via a SimpleMarkerSymbol.
SimpleRenderersThis sample demonstrates how to create a simple renderer and add it to a graphics overlay. Renderers define the symbology for all graphics in a graphics overlay (unless they are overridden by setting the symbol directly on the graphic). Simple renderers can also be defined on feature layers using the same code.
SketchOnMapThis sample demonstrates how to interactively sketch and edit graphics in the map view and display them in a graphics overlay. You can sketch a variety of geometry types and undo or redo operations.
SpatialRelationshipsThis sample demonstrates how to use the GeometryEngine to evaluate the spatial relationships (for example, polygon a contains line b) between geometries.
SurfacePlacementsThis sample demonstrates how to position graphics using different Surface Placements.
UseDistanceCompositeSymThis sample demonstrates how to create a `DistanceCompositeSceneSymbol` with unique marker symbols to display at various distances from the camera.
ViewshedGeoElementDisplay a live viewshed analysis for a moving GeoElement.
ViewshedLocationThis sample demonstrates the configurable properties of viewshed analysis, including frustum color, heading, pitch, distances, angles, and location.