1

I want to get some pointer events like

  • long tap
  • right click

Are there any examples or documentations for archive them?

  • for right click, see this answer and the valuable comments. Choose a value of "2" for right clicks. – JGH Sep 11 '18 at 18:08
1

I found the solution by myself for long tap:

var longpress = false;
map.on("click",function(e){
    (longpress) ? alert("Long Press") : alert("Short Press");
    console.log(map.getEventCoordinate(e.pixel));
});
var startTime, endTime;
map.on('pointerdown', function () {
    startTime = new Date().getTime();
});
map.on('pointerup', function () {
    endTime = new Date().getTime();
    console.log(endTime - startTime);
    longpress = (endTime - startTime < 500) ? false : true;
});

Your Answer

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

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