Map Touch Tap To Mouse Click?

8270
21
01-12-2011 09:33 AM
RyanCoodey
Occasional Contributor III
I am new to working with touch screens but we have a few and the touch gesters work great such as pan and zoom.  We have a toolbar with a few tools such as an identify tool and a measure tool, etc... these are listening for the mouse click event on the map... 

What is the best way to handle both touch taps and mouse clicks?

1) For each tool we created do I need to handle both the MouseClick and the TouchUp events?
2) This wont work for the measure action though because that is an action (which has the clicking embedded), so how do we use the measure action with touch?

Thanks a lot for any info!

*EDIT*
So in I tried this in one of my tools:
        map.MapGesture += Identify_MapGesture;
        ...

        protected void Identify_MapGesture(Object sender, ESRI.ArcGIS.Client.Map.MapGestureEventArgs e)
        {
            if(e.Gesture == GestureType.Tap)
            {
                ESRI.ArcGIS.Client.Map.MouseEventArgs mouseEventArgs = new ESRI.ArcGIS.Client.Map.MouseEventArgs();
                mouseEventArgs.MapPoint = e.MapPoint; 
              Identify_MouseClick(sender, mouseEventArgs);
            }
        }

And it works pretty good...
0 Kudos
21 Replies
RyanCoodey
Occasional Contributor III
No, ToolbarItemClicked is hit with both the mouse and the touch... MeasureAction.Execute() is executed both ways.  It�??s just that the measure action does not respond to map touches, just to map clicks.  Kind of weird...
0 Kudos
RyanCoodey
Occasional Contributor III
I found another related issue too with my application on a touch screen:

GraphicsLayer.MouseLeftButtonUp is an ESRI event, so as you said before it is not called with a touch... but I do not see any touch related events in GraphicsLayer so how can I handle this?  I have an eraser tool on our graphic toolbar so with this tool, when you click on a graphic (hence the GraphicsLayer.MouseLeftButtonUp) it can then remove the graphic.

Still havn't figured out why the measure works with the mouse and not the touch in the app either...  still poking around with it though.

Thanks for all the help so far!

*EDIT*
Looks like I might be able to hook up an event handler to each individual graphic... would be nice to just hook up to the graphic layer though
0 Kudos
RyanCoodey
Occasional Contributor III
Graphic.MouseLeftButtonUp doesn't fire on touch tap either (and its uses Microsoft's event args), so that didn't work 😞
0 Kudos
JenniferNery
Esri Regular Contributor
If you would like to get the graphic based on touch gesture you can do something like:
 double tapTolerance = 30;
 private void MyMap_MapGesture(object sender, Map.MapGestureEventArgs e)
 {
  if (e.Gesture == GestureType.Tap)
  {
   IEnumerable<Graphic> graphics = e.DirectlyOver(tapTolerance, new List<GraphicsLayer>() { layer });
   if (graphics != null && graphics.GetEnumerator().MoveNext())
   {
    Graphic graphic = graphics.First();
    
   }
  }
 }


http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Map+MapGes...
0 Kudos
RyanCoodey
Occasional Contributor III
Jennifer, Thanks so much for all the help!

That solved my problem for my graphic erase tool... maybe in the future Graphic and GraphicsLayer events will directly support touch too :).

I still cannot get the MeasureAction to work though.  It seems to be an issue with WPF, that Silverlight does not have.  I recreated that Silvelright sample you linked to above in WPF and it does not work with taps, just clicks.  I wonder if it is a similar issue to what I posted here: http://forums.arcgis.com/threads/21149-Slider-Inside-Of-Legend-Does-Not-Work-With-Touch-Screen-(Only...)

Thank you much!
0 Kudos
JenniferNery
Esri Regular Contributor
No problem.

I am also puzzled why your MeasureAction does not respond to touch events when you say that all code is reached.

I also read your post about the Slider but I have not had the chance to replicate it yet. It could be because of some tolerance issue? Maybe you need to increase the size of the slider to accommodate touch gesture.
0 Kudos
RyanCoodey
Occasional Contributor III
Did you try the MeasureAction in WPF on a touch screen?

With the slider, I don't think it is a tolerance or size issue... I can clearly select the slider's thumb.  I think it is due to the fact that the Legend/Treeview control has scroll bars (only visible if needed) and those are capturing the touch slide gesture.

Thanks Jennifer!
0 Kudos
LeonKosiba
New Contributor
I am having the same issue where the measure action where it will not work on a newer touch screen, when trying to measure by tapping on the screen. 
I�??m using  ArcGISWPFSDK_DotNet40_VBNet.sln compiled using v2.2 ESRI assemblies.
The sample application works when using a pen with the touch screen.  When using the Silverlight application I can measure by tapping on the screen.
I�??m using a new touch screen that supports gestures, when I try this on an older screen that doesn�??t support gestures I�??m able to measure by tapping.
0 Kudos
johnbrosowsky
Occasional Contributor II
Hi Jennifer - the example you cite is for the ArcGIS API for Silverlgiht, and it does work with touch, but only sort of.  Using the mouse you can click to measure and double click to stop measuring.  Using touch you can tap to measure, however double tapping to stop measuring makes the map zoom in which is not expected or desirable.

However, can you please try the corresponding exmaple for the ArcGIS API for WPF:

http://help.arcgis.com/en/webapi/wpf/samples/start.htm

... the corresponding ArcGIS API for WPF interactive sample -> behaviours and actions - utility actions - > measure:

It most definitley does not work with a touch screen, and is different behavior than in the Silverlight example.

Do you know how to make it work with the WPF example?
0 Kudos
ae
by
Occasional Contributor II
Did any of you ever figure out how to make measureactions work with touch input?

Cheers
0 Kudos