Select to view content in your preferred language

Javascript touch support for Android

4299
5
09-13-2010 08:33 AM
JacobBartruff
Deactivated User
Has anyone tried the touch samples within the Android browser?  The examples work great under iOS but they do not work on the Android devices I have tried.  Has anyone had success getting touch panning to work and such?
0 Kudos
5 Replies
SteveGrise
Regular Contributor
I have had similar issues on my Android NexusOne. When I click the map it is like I am selecting the html element rather than firing onclick or the multi-touch events I really want. I just presumed this will be fixed at Javascript 2.1 (based on my reading between the lines on the blog posts), but I don't know for sure.

Steve
0 Kudos
NianweiLiu
Frequent Contributor
This has nothing to do with ESRI's API, so V2.1 is not going to help you.

The issue is that Android browser currently does not expose full multi-touch guesture events to javascript runtime. It has very limited touchstart, touchend interface, but only for one finger.

There is no time-table committed by the Google Android team on this issue.
0 Kudos
JacobBartruff
Deactivated User
I understand that the Android browser does not expose multi-touch events to the JavaScript runtime.  This is why we must have zoom in and out buttons but that does not explain why we cannot pan.  This site works on my Android phone.
0 Kudos
SteveGrise
Regular Contributor
My issue is not with multi-touch, that seems to work fine. My issue is with click/onClick. After more testing/research I found out that the usual "onClick" events we associate with the map control in ArcGIS apps doesn't happen. Instead I see a "click" event on the parent of the map element in my app, in this example it is called "mainView".

In this code example I check if the browser is Android, and if the click is on the mainView/map element then I call the onclick event I have also connected in the onLoad function.

in my Init() function{
...
  dojo.connect(map, "onLoad", function(evt) {
...

if (navigator.userAgent.indexOf('Android') != -1 ) {
  dojo.connect(dojo.byId("mainView"), "click", function(evt) {
    if (evt.target) targ = evt.target;
    else if (evt.srcElement) targ = evt.srcElement;
    if (targ.nodeType == 3)
      targ = targ.parentNode; // apparently a Safari difference/fix
    //alert(targ.id + " " + evt.type + " " + evt.screenX + "," + evt.screenY);
    if(targ.id.indexOf("map") != -1 && targ.id.indexOf("layer") != -1) {
      map.onClick(evt);
    }
  });
}                                                                                                              

...
0 Kudos
DavidBennett1
New Contributor
Please star this bug on the Android bug list:

http://code.google.com/p/android/issues/detail?id=11909

Let's see if we can raise awareness of this issue.
0 Kudos