0 Replies
      Latest reply on Sep 25, 2019 6:22 AM by Hoshi
      Hoshi Level 1 Level 1 (0 points)

        Hello,

         

        I am integrating a mapkit JS map on a website. I need to use either the click or dblclick event for some custom actions, but I run into problems with both.

         

        1) click event

         

        Everything is working fine with this code (found on this forum here https://forums.developer.apple.com/thread/109735):

         

        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;

              }

          //  my code here

           });

         

        Only problem, it is also fired when the map is dragged. It is actually fired at the end of the drag, and the coordinate of the event corresponds to the point on the map used to perform the drag.

        Is there a way to create a click event which will not fire when a drag is performed?

         

        2) double click event

         

        Using the double click instead of a simple click is an option. However, the double click triggers a zoom. I don't want to disable all zooming capabilities through isZoomEnabled. I couldn't find any construction option dealing with the double click zoom.

        I tried the following to prevent the native zoom behavior but with no luck:

         

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

             event.preventDefault();  

             event.stopPropagation();

          });

         

        Is there a way to disable the double click zoom without impacting the zooming via controls?

         

        Thank you for your help!