“Who needs more than one finger?” — Android
After Tim Schaub got pinch-zoom into trunk yesterday with some excellent work and debugging from him and Bruno Binet, I was excited to see people able to use OpenLayers for easy navigation of the map on browsers with touch events. Turns out, my excitement was misplaced: though the functionality is functional (and super-slick!) on iOS devices greater than v2.0, on the Android platform, it’s not.
Turns out, the reason is simple: Android browsers don’t implement multitouch at the Javascript level.
You can zoom an Android page by using two fingers to pinch, but those events are never delivered to the DOM as multiple touch events; instead, we simply get one touch, no matter how many fingers are interacting with the screen.
Using the Multitouch Test OpenLayers example, I’ve gotten reports from far and wide, from 2.1 all the way up to 2.3 (Gingerbread): the Android browser only supports one touch event. For comparison? iOS supports up to 5.
The OS supports these events: In fact, a multitouch-on-Android development article suggests behavior very similar to the browser events. (There is a slight difference; in the browser DOM, you don’t get different events for DOWN vs. POINTER_DOWN; they’re both a touchstart.) You have a series of move events, and each move has a list of touches attached to it — in iOS/Safari, these equate to the evt.touches array of Touch objects attached to the TouchEvents.
This documentation has been around for almost 3 years — the functionality existed in iOS before the T-Mobile G1 device even shipped (in October of 2008). The touch events in Android for single touches map pretty much exactly to Apple’s spec, but no multitouch support exists at the DOM level, and no clearly documented plans to.
I just hope that the plan on the Android side isn’t to wait until the webevents W3C group ships a Recommendation in 2012…
May 24th, 2011 at 7:09 am
When my galaxy s was running on Android 2.1 (Eclair) pinch zoom in openlayers worked perfectly well.
Now that I’ve upgraded to 2.2 (froyo) pinch zoom is broken.
Not Nice … But it is shown that it can be done. Then it should be possible to redo?
June 1st, 2011 at 3:08 am
Marco: It’s not really something that is within what OpenLayers can do anything about. Some android devices support it. Some don’t. Talk to Samsung, not us 🙂
September 14th, 2011 at 12:49 pm
OpenLayers works great on my HD2 and I use Android 2.2 no problem it very smooth.