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);
}
});