I can't get the mousedown event to fire on a mobile device when I click on a marker. I'm using openlayers 2.11 with TouchNavigation. The mousedown event fires just fine in Chrome on my Desktop. Are there touch specific events for openlayers? If yes, where can Ifind the list. The openlayers documentation is driving me crazy.

The code I use:

  var start_point = new OpenLayers.LonLat(latlngs[0].x,latlngs[0].y);
  var start_marker = new OpenLayers.Marker(start_point,green_pin);
  start_marker.events.register('mousedown', start_marker, function(evt) { alert('Ok'); OpenLayers.Event.stop(evt); });
  • Why I can't using events "touchstart"? Commented Dec 2, 2013 at 3:18
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. Commented Dec 2, 2013 at 3:58

2 Answers 2


I had basically the same question as user506706. I just couldn't believe that the Vector layer was the only layer to handle touches...so if all else fails...read the code. In OpenLayers-2.11/OpenLayers/lib/Events.js I found:

    "mouseover", "mouseout",
    "mousedown", "mouseup", "mousemove",
    "click", "dblclick", "rightclick", "dblrightclick",
    "resize", "focus", "blur",
    "touchstart", "touchmove", "touchend"

So in my existing code that currently uses a Marker layer, I register a handler for the touchstart event...

new_marker.events.register("touchstart", new_marker, function(e) {
                        console.warn("touch start");                                       

I tested on my iPod Touch/Safari Browser and voila...touching the marker got the touchstart event. Upon further debugging to the console, I believe it also gets the mouseover and mouseout events, but not the mousedown mentioned. Hope this helps.

  • RefactorFun ::: your super right Commented Apr 19, 2012 at 13:48
  • Awesome man.. Saved my day.. I was literally pushed to the wall... Thanks for sharing this..
    – Roy M J
    Commented Jan 6, 2014 at 5:54

Correct, the mousedown events do not occur on mobile with Touch events. Instead, you should use a Vector layer -- the Vector layers appropriately handle 'taps' and interpret them as select events.

  • Markers should now be put on the Vector layer. I think OpenLayers is slowly planning to depreciate the MarkerLayer.
    – fnllc
    Commented Mar 8, 2012 at 21:04
  • So is it impossible to get a click event on the map itself? I'm handling searching on the server side, so I need a generic click event also on the iPad, that's why. Commented Apr 23, 2012 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.