I deleted this question which I posted a few days ago, thinking that I would be able to solve it. But after struggling for some time, I think I really need some help. The problem is this: I am testing my map application on a touch device. There are a number of click listeners registered on the map and markers. I would expect these listeners to be able to respond to touch events that consist of a tap which is equivalent to a mouse click.

Some listeners work; some don't. Example, the base layer switcher button on the top right corner of the map respond to the click. However, the map and the markers don't. While examining the Openlayers javascript debug file. I notice that click handlers are assigned to the map, map navigation control and buttons. The buttons respond to the touch click event perfectly; the map is able to zoom in on double tap; which leads me to conclude that something must be wrong with the navigation control.

There is an awkward solution that suggested doing this:

// create click control class
OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
 defaultHandlerOptions: {
  'single': true,
  'double': false,
  'pixelTolerance': 0,
  'stopSingle': false,
  'stopDouble': false
 initialize: function(options) {
  this.handlerOptions = OpenLayers.Util.extend(
   {}, this.defaultHandlerOptions
   this, arguments
  this.handler = new OpenLayers.Handler.Click(
   this, {
    'click': this.trigger
   }, this.handlerOptions

// add click control
var clickControl = new OpenLayers.Control.Click({
 trigger: function(e) {
// do whatever

There are two related questions here and here. But till now, there seems to be no one able to point out what went wrong with the navigation control and how to solve this.

I spent a few days pouring through the code trying to decipher what is going on, but no luck so far. To me, the above solution causes a noticeable delay in the clicks which affected other function calls. Therefore, I am posting this to see if anyone can help. Thanks.

  • What kind of Touch Device? Android or iOS? I remember there were some issues with the stock browser in Android not passing on the Multitouch events to Openlayers. – Devdatta Tengshe Nov 22 '12 at 4:30
  • Have you looked at this page: docs.openlayers.org/library/mobile.html? – Devdatta Tengshe Nov 22 '12 at 4:32
  • @DevdattaTengshe, it's an Android. I know that Android browsers are not capable of multi-touch. But this is regarding single touch. – Question Overflow Nov 22 '12 at 4:33
  • @DevdattaTengshe, err, it's not related to the problem I am facing. Panning and zooming the map with touch is not a problem here. My problem is more on making map.events.register("click".. to work with touch device. – Question Overflow Nov 22 '12 at 4:38
  • Sorry, I totally misunderstood your issue. Please disregard my previous comment. – Devdatta Tengshe Nov 22 '12 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.