Tuesday, 21 August 2018

Will mousedown events fire with Touch events on OpenLayers mobile?


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); });
StartFinishLayer.addMarker(start_marker);

Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...