1

I'm using Mapboxgl in angular, and I have this code and everything is well:


map!: mapboxgl.Map;
loadMap()
{
   (Mapboxgl as any).accessToken = environment.mapBoxKey;
   this.map = new Mapboxgl.Map({
      container: 'map-box', // container id
      style: 'mapbox://styles/mapbox/streets-v11',
      center: [5, 51], // starting position
      zoom: 5 // starting zoom
    });
}

When I add 'click' event to the map, the double click zoom not working. this is the 'click' event code:


this.map.on('click', (e) =>{
      if(this.marker != null){
        this.marker.remove();
      }
      //creatMarker(e.lngLat.lng, e.lngLat.lat);
    });

how can fix that?

Mu nt
  • 93
  • 1
  • 1
  • 9
  • I think I personally understand what you mean because I am having a similar issue. You want to do something on click but exclude a double click. Almost like a single click event. I think the way to go is to have a click event and detect when you are in a double click and if so, not do anything. I am currently trying to find out exactly. If I do, I'll post the solution. – Mig Aug 14 '23 at 14:05
  • Something like this: https://stackoverflow.com/questions/5497073/how-to-differentiate-single-click-event-and-double-click-event/60177326#60177326 – Mig Aug 14 '23 at 14:08

1 Answers1

-1

For double click use dblclick insted of click

Vasile Radeanu
  • 824
  • 5
  • 17