layer.Graphics not there

2221
2
01-08-2016 09:57 AM
ScottRowles
New Contributor

Hi,

I have a WinForms application in VS 2013.  I have referenced the arcgisruntime and can create a graphics layer in the mapcontrol, but the GraphicsLayer that I am creating isn't showing a binding for the Graphics property of the layer for me to add Points, Lines and Polygons.

using System;

using System.Collections.Generic;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Esri.ArcGISRuntime.Controls;

using Esri.ArcGISRuntime.Layers;

using Esri.ArcGISRuntime.Symbology;

using Esri.ArcGISRuntime.Geometry;

using HB.Core.Inventory;

using HB.Core.Tasking;

-----other methods here

        private Boolean DrawLocations()

        {

            try

            {

          

                //Draw All Locations

                Layer layer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

                layer.ID = "Locations";

                layer.DisplayName = "Locations";

                mapControl.Map.Layers.Add(layer);

                foreach (Location location in Data.GetLocations())

                {

                    Esri.ArcGISRuntime.Geometry.MapPoint point = new MapPoint(location.Point.X, location.Point.Y, location.Point.Z);

                    Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol symbol = new SimpleMarkerSymbol();

                    Esri.ArcGISRuntime.Layers.Graphic graphic = new Graphic(point, symbol);

                    layer.Graphics.Add(graphic);

                }

                return true;

            }

            catch (Exception ex)

            {

                throw new Exception("Unable to Draw Locations.", ex);

            }

        }

Any help would be appreciated!

scott

0 Kudos
2 Replies
GrigoriyGorodisskiy
New Contributor

Try set  SpatialReference for points.

...

Esri.ArcGISRuntime.Geometry.MapPoint point = new MapPoint(location.Point.X, location.Point.Y, location.Point.Z, SpatialReferences.Wgs84)

...

0 Kudos
AnttiKajanus1
Occasional Contributor III

Hi,

Could you make sure that your graphics are in the same SpatialReference with MapView.

0 Kudos