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

229
Vistas
How to make a function run only during a click, not a click and drag

I have a function that grabs the mouses lat and long in cesium when the mouse is clicked. However, if you drag, it still runs the function. I put an if statement in the function to make sure it runs when my variable, app.drag is false. app.drag is turned to true when the mouse moves. Now I need to check when the mouse has stopped so app.drag can go back to false. Doing !'mousemove' doesn't work so how do you do that? I think this is the best method to check if the mouse is dragged, but if there's a simpler way, please let me know. My code:

    app.drag = false;
    app.viewer.scene.canvas.addEventListener("mousemove", () => app.drag = true);
    app.viewer.scene.canvas.addEventListener("click", function(e) {
      if (!app.drag) {
        let ellipsoid = app.viewer.scene.globe.ellipsoid;
        let cartesian = app.viewer.camera.pickEllipsoid(new Cesium.Cartesian3(e.clientX, e.clientY), ellipsoid);
        let cartographic = ellipsoid.cartesianToCartographic(cartesian);
        let latitude = Cesium.Math.toDegrees(cartographic.latitude);
        let longitude = Cesium.Math.toDegrees(cartographic.longitude);
        document.getElementById("lat").value = Math.round(latitude);
        document.getElementById("lon").value = Math.round(longitude);
      }
    });
about 4 years ago · Juan Pablo Isaza
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