mapkit js mobile click

Hello,


mapkit js doesn't seem to get a lot of traction on the forum. Is this the right place to talk about it?

Anyway, I am facing something very weird and I'd like to share it to try to find a solution. I am developing a website using mapkit js. I need to perform a certain action on the click (or tap) event. It works perfectly on desktop (safari, chrome and firefox), but somehow the click event doesn't fire on iphone or ipad (with safari and chrome).


The code looks like that:


map.element.addEventListener("click", function(event) {

if (event.target.parentNode !== map.element) {

// This condition prevents clicks on controls. Binding to a

// secondary click is another option to prevent conflict

return;

}

alert("click on map");

});


The double tap is triggering a zoom, so the framework is catching the taps, but somehow the tap doesn't trigger the click (all other map framework I use do). Is this a normal behavior? Is there a way to make the tap work as a click, or to catch the tap event?


Thank you for help!

Answered by Hoshi in 385019022

Solution was by using the "single-tap" event which was released in version 5.18.0. Events documentation has not been updated since then 😠 and I only found out about it by reading all the release notes. Got lucky there 🙂

Accepted Answer

Solution was by using the "single-tap" event which was released in version 5.18.0. Events documentation has not been updated since then 😠 and I only found out about it by reading all the release notes. Got lucky there 🙂

Great find. Thank you. Unfortunatly 5.17 breaks dragging annotations, so currently I am left standing in the rain: Either I can move annotations or I can recognize taps on mobile. But for my app I need both. Considering the fact that we are already at 5.29.0 and no one noticed this. I looks like the library is not really being used...

mapkit js mobile click
 
 
Q