Select to view content in your preferred language

IdentifyTask not working on touch enabled devices

882
2
Jump to solution
01-04-2013 11:13 AM
BobNichols
Regular Contributor
Ran into a problem today when viewing my Silverlight App on a laptop that had a touch screen.  Everything works except when trying to "Click" or tap on a property to identify it.  The identify task doesnt run unless I grab the mouse and click.  Screen taps appear to not work.  I wanted to see if it was my app or not so I viewed the live samples on this site and sure enough it doesnt work there either.  Is this a limitation of Silverlight or is there a different click event that needs to be run when a user taps the screen rather than click?  I tried searching this site and using the google but came up with nothing.  Thanks!
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
The identify task doesnt run unless I grab the mouse and click.  Screen taps appear to not work.


It's depending on the event you subscribe to execute your identify task.
If you subscribe to MouseClick event only, the identify task won't run on Tap event.

You have to subscribe to tap or, better, MapGesture event as well.

Another approach consists to use a Draw object in Point DrawMode and to execute the identify task when the draw completed.
The Draw object includes snapping capabilities so this approach is recommended.

I wanted to see if it was my app or not so I viewed the live samples on this site and sure enough it doesnt work there either.

You are right. We are considering to enhance the samples to get a better support of the touch screens.

View solution in original post

0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
The identify task doesnt run unless I grab the mouse and click.  Screen taps appear to not work.


It's depending on the event you subscribe to execute your identify task.
If you subscribe to MouseClick event only, the identify task won't run on Tap event.

You have to subscribe to tap or, better, MapGesture event as well.

Another approach consists to use a Draw object in Point DrawMode and to execute the identify task when the draw completed.
The Draw object includes snapping capabilities so this approach is recommended.

I wanted to see if it was my app or not so I viewed the live samples on this site and sure enough it doesnt work there either.

You are right. We are considering to enhance the samples to get a better support of the touch screens.
0 Kudos
BobNichols
Regular Contributor
Thank You!!! You got me pointed in the right direction!  I used the MapGesture Event and did a quick if statement to determine whether the user did a tap then ran my identify task. 

[INDENT]private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs args)
        {
            if (args.Gesture == GestureType.Tap )
            {
                GraphicsLayer layer = this.MyMap.Layers["IdentifyIconGraphicsLayer"] as GraphicsLayer;
                layer.ClearGraphics();
                Graphic graphic2 = new Graphic
                {
                    Geometry = args.MapPoint,
                    Symbol = this.LayoutRoot.Resources["CougarWait"] as Symbol
                };
                Graphic item = graphic2;
                layer.Graphics.Add(item);
                IdentifyTask task = new IdentifyTask("http://......./MapServer");
                task.ExecuteCompleted += new EventHandler<IdentifyEventArgs>(this.IdentifyTask_ExecuteCompleted);
                task.Failed += new EventHandler<TaskFailedEventArgs>(this.IdentifyTask_Failed);
                IdentifyParameters identifyParameters = new IdentifyParameters
                {
                    LayerOption = LayerOption.all,
                    SpatialReference = this.MyMap.SpatialReference,
                    MapExtent = this.MyMap.Extent,
                    Width = (int)this.MyMap.ActualWidth,
                    Height = (int)this.MyMap.ActualHeight,
                    Geometry = args.MapPoint
                };
                task.ExecuteAsync(identifyParameters);
            }
          
        }[/INDENT]

Thanks again for your help!
0 Kudos