Question

I want to set markers on a Leaflet map. To achieve this I tried jquery-mobile-events with minor success. This is how I integrated it:

$(map).off('taphold');
$(map).bind('taphold', function(e, options){
... do something ...
});

It works on the desktop but not on mobile. 'map' is a L.map object. An other problem which is associated with it is that I can not get options.startPosition and options.endPosition. I need this to create a distinction between a long tap for panning the map and one to place a marker. Does anyone know a solution to this?

Was it helpful?

Solution

There is actualle a really neat implementation in Leaflet for this:

map.on('contextmenu', function(e){
  .. do something ...
});

The problem is that it is also triggerd by clicking rightclick on desktop.

Edit: You can prevent it by checking if (event.button == 2) {...}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top