Select to view content in your preferred language

Identify task without click

990
2
07-09-2010 06:43 AM
BrianGustafson
New Contributor III
Is there a way to run an identify task without the user clicking on the map?  I have tried creatting a point from lat\longs and then putting that in the geometry property of the parameters but it returns no results.  I also tried creating Map.Mouseevent and putting that in the geometry and that did not work either.  Has anyone tried this?
0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor
Yes this should work. Did you set the spatial reference on the point you created?
0 Kudos
BrianGustafson
New Contributor III
This is the code I am using.  It is the same code from when the click event is fired on the map.  the click event works and the one below does not.  The lat\longs of the click and the input are the same.


//run identifytask for selected station to get the data to populate the datagrid
            IdentifyTask identifyTask = new IdentifyTask("http://arcgisd/ArcGIS/rest/services/Facilities/MapServer");//fix
            identifyTask.ExecuteCompleted += IdentifyTaskPostEdit_ExecuteCompleted;
            identifyTask.Failed += IdentifyTask_Failed;

            IdentifyParameters identifyParameters = new IdentifyParameters();
            identifyParameters.LayerOption = LayerOption.all;
            identifyParameters.Tolerance = 20;

            //Pass current Map properties to identify parameters
            identifyParameters.MapExtent = MyMap.Extent;
            identifyParameters.Width = (int)MyMap.ActualWidth;
            identifyParameters.Height = (int)MyMap.ActualHeight;

            //Identify features at the click point
            identifyParameters.LayerIds.Add(0);
            identifyParameters.SpatialReferenceWKID = MyMap.SpatialReference.WKID;
            Map.MouseEventArgs mousecords = new Map.MouseEventArgs();
            mousecords.MapPoint = new MapPoint();
            mousecords.MapPoint.X = dLongX;
            mousecords.MapPoint.Y = dLatY;
            mousecords.MapPoint.SpatialReference = MyMap.SpatialReference;

            identifyParameters.Geometry = mousecords.MapPoint;

            identifyTask.ExecuteAsync(identifyParameters);
0 Kudos