Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
Mapbox mousemove Event Listener not Disabling

I'm using the mousemove event listener in mapbox to be able to drag a point around the map. However, when I'm calling .off() on it, it isn't disabling. I'm doing this in Angular with Typescript.

Original Call:

this.map.mapInstance.on('mousemove', this.onPointMove.bind(this));
this.map.mapInstance.once('mouseup', this.onPointUp.bind(this));

onPointMove(e):

const coords = e.lngLat;

this.map.mapInstance.getCanvasContainer().style.cursor = 'grabbing';

console.log(coords);

onPointUp(e):

this.map.mapInstance.getCanvasContainer().style.cursor = '';

this.map.mapInstance.off('mousemove', this.onPointMove.bind(this));

After I finish dragging, the console.log still gets outputted when I move my mouse around.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your problem is you need to pass the exact same function to off, not a new function which does the same thing.

const mousemove = this.onPointMove.bind(this);
this.map.mapInstance.on('mousemove', mousemove);

// ...

this.map.mapInstance.off('mousemove', mousemove);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda