Feature Layer double TAP point

3608
12
Jump to solution
05-15-2014 12:17 PM
JeffPace
MVP Regular Contributor
I am having trouble listening for a double tap event on a feature layer point.

Click and dbl click work fine on the desktop.  Tap works fine to select a point on iOS.  But I can't seem to get doubletap to fire

I even tried using the dojox/gestures but to no avail

Any ideas?
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor
Well, I kind of found hacky workaround.

Double-tap works, still testing other gestures like hold.

// get the map id, coincides with DOM element id. var nodeId = this.map.id; // get the graphics container node, it looks like "map-id_gc" var node = dom.byId(nodeId+'_gc'); // listen for doubletap on the graphics container of svg graphics on(node, tap.doubletap, lang.hitch(this, function(e) {     // I keep an array of layers to search through, but you could just     // work off a single layer     arrayUtils.forEach(layersArray, function(lyr) {       var i = lyr.graphics.length;       while(i--) {         // get a graphic         var graphic = lyr.graphics;         // get the node of the graphic         var gnode = graphic.getNode();         // if the node and the doubletap target are a match         // do what you want to do         if (gnode === e.target) {           e.graphic = graphic;           // I pass this on to my original double-click           // handler and just add the graphic to the event           // pretty much a duplicate of the dbl-click event           this.onLayerDblClick(e);         }       }     }, this);   }) );


This is working so far, I'm just going to see if I can incorporate Modernizr tests to check for when I have to do this.
https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js

*edit - this does work for hold too, so I'm pretty happy with it. Although hold seems to have same issues discussed here http://forums.arcgis.com/threads/111887-Graphics-mouse-down-alert-boom.
That work around doesn't seem to work with hold, so as long as I distinguish when to use which events based on touch events, everything works as expected.

View solution in original post

12 Replies
JeffPace
MVP Regular Contributor
anyone? could really use some guidance on this
0 Kudos
JeffPace
MVP Regular Contributor
still really struggling here.  FeatureLayer has click, dbl-click, mouse over, mouse out, etc.. where are the touch events?
0 Kudos
JeffPace
MVP Regular Contributor
to the top. anyone?
0 Kudos
ReneRubalcava
Frequent Contributor
You ever hear anything? This is holding me up on something too.
Double-click or double-tap, whatever is used internally must work in the API, because I can use it to zoom in the map, just not on FeatureLayers.
0 Kudos
JeffPace
MVP Regular Contributor
nothing.  I am about to delve into the obfuscated API.
0 Kudos
ReneRubalcava
Frequent Contributor
Well, I kind of found hacky workaround.

Double-tap works, still testing other gestures like hold.

// get the map id, coincides with DOM element id. var nodeId = this.map.id; // get the graphics container node, it looks like "map-id_gc" var node = dom.byId(nodeId+'_gc'); // listen for doubletap on the graphics container of svg graphics on(node, tap.doubletap, lang.hitch(this, function(e) {     // I keep an array of layers to search through, but you could just     // work off a single layer     arrayUtils.forEach(layersArray, function(lyr) {       var i = lyr.graphics.length;       while(i--) {         // get a graphic         var graphic = lyr.graphics;         // get the node of the graphic         var gnode = graphic.getNode();         // if the node and the doubletap target are a match         // do what you want to do         if (gnode === e.target) {           e.graphic = graphic;           // I pass this on to my original double-click           // handler and just add the graphic to the event           // pretty much a duplicate of the dbl-click event           this.onLayerDblClick(e);         }       }     }, this);   }) );


This is working so far, I'm just going to see if I can incorporate Modernizr tests to check for when I have to do this.
https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js

*edit - this does work for hold too, so I'm pretty happy with it. Although hold seems to have same issues discussed here http://forums.arcgis.com/threads/111887-Graphics-mouse-down-alert-boom.
That work around doesn't seem to work with hold, so as long as I distinguish when to use which events based on touch events, everything works as expected.

View solution in original post

ReneRubalcava
Frequent Contributor

I'm curious if getting double-tap to work in an upcoming version of the API is on the roadmap anywhere. Mobile editing is pretty key and although the hack I posted still works, I am finding it can interfere with some other click events on the map. I am still trying to work around this issue in my particular case, so it may work fine for others. It would however be nice if the API could check for touch events and fallback to those as needed behind the scenes.

By the way, I have created a widget that implements the above hack.

odoe/esri-simpleedit-widget · GitHub

JeffPace
MVP Regular Contributor
absolutely beautiful.

I already had a layerArray that i use as well, so this just dropped in.

Many many thanks
0 Kudos
JeffPace
MVP Regular Contributor

it didnt work for me b/c of the click event conflicts.  Jonathan Uihlein‌ indicated it is on the roadmap, but I am not sure where.

It is desperately need.

0 Kudos