AnsweredAssumed Answered

Get Selected GraphicsLayer from Map

Question asked by Initlipton on Jan 29, 2016
Latest reply on Jan 29, 2016 by Gagandeep_Singh-esristaff

In my IOS app i've drawn a number of graphics onto the Map. In the TouchesBegin event that is fired when a user interacts with the map i cant figure out how to tell if the point interacts with one of the graphics.

 

I've binded the SDK to C#. The objects and the process should be the exact same as in a natively developed app

 

public override void TouchesBegan(NSSet touches, UIEvent evt)

        {

            if (!this.Loaded) return;

            try

            {

                base.TouchesBegan(touches, evt);

 

                var touch = touches.AnyObject as UITouch;

 

                if (touch == null) return;

 

                var p = new AGSIdentifyParameters()

                {

                    Tolerance = 20,

                    Dpi = 98,

                    LayerOption = AGSIdentifyParametersLayerOption.All

                };

           

                var identityPoint = ToMapPoint(touch.LocationInView(this));

                p.Geometry = identityPoint;

                p.SpatialReference = identityPoint.SpatialReference;

                p.MapEnvelope = this.MaxEnvelope;

                p.Size = new CGSize(UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width);

 

 

//AFTER HERE IS WHERE I AM GETTING LOST. IM NOT SURE HOW TO FIND THE GRAPHIC I WANT TO INTERACT WIT

 

                var gs = GraphicsLayer.SelectedGraphics;

               

                var result = GraphicsLayer.Graphics.FirstOrDefault(i => i.Geometry.Envelope.ContainsPoint(identityPoint));

 

                if (result != null)

                {

                    var r = result.Geometry;

                }

            }

            catch (Exception ex)

            {

                Analystics.Instance.LogError(ex,"Issue occured in the ontouch event on the Map");

            }

Outcomes