Solved! Go to Solution.
var mouseMovedAfterDown = false; var mouseDownHandler = null; var map = null //this is setup elsewhere.
// some geometries will automatically draw at a set size relative to the current map scale if the mouse isn't moved. // We don't want this to happen though, to avoid it we add these listeners and get the drawn geometry's center when that occurs. var watchMouseMoveAfterDown = function () { var mouseLocation = null; function mouseDown(event) { mouseMovedAfterDown = false; console.log("mouseMovedAfterDown = false"); mouseLocation = { x: event.clientX, y: event.clientY }; jQuery(document).on("mousemove", mouseMove); console.log("mousemove added"); dojo.disconnect(mouseDownHandler); if (!rootScope.$$phase) rootScope.$apply(); } function mouseMove(event) { if (event.clientX !== mouseLocation.x || event.clientY !== mouseLocation.y) { mouseMovedAfterDown = true; console.log("mouseMovedAfterDown = true"); jQuery(document).off("mousemove", mouseMove); console.log("mousemove removed"); if (!rootScope.$$phase) rootScope.$apply(); } } if (mouseDownHandler) dojo.disconnect(mouseDownHandler); mouseDownHandler = dojo.connect(map, "onMouseDown", mouseDown); };
watchMouseMoveAfterDown();
if (!mouseMovedAfterDown && geometry.type !== "point") { geometry = geometry.getCentroid(); }
var mouseMovedAfterDown = false; var mouseDownHandler = null; var map = null //this is setup elsewhere.
// some geometries will automatically draw at a set size relative to the current map scale if the mouse isn't moved. // We don't want this to happen though, to avoid it we add these listeners and get the drawn geometry's center when that occurs. var watchMouseMoveAfterDown = function () { var mouseLocation = null; function mouseDown(event) { mouseMovedAfterDown = false; console.log("mouseMovedAfterDown = false"); mouseLocation = { x: event.clientX, y: event.clientY }; jQuery(document).on("mousemove", mouseMove); console.log("mousemove added"); dojo.disconnect(mouseDownHandler); if (!rootScope.$$phase) rootScope.$apply(); } function mouseMove(event) { if (event.clientX !== mouseLocation.x || event.clientY !== mouseLocation.y) { mouseMovedAfterDown = true; console.log("mouseMovedAfterDown = true"); jQuery(document).off("mousemove", mouseMove); console.log("mousemove removed"); if (!rootScope.$$phase) rootScope.$apply(); } } if (mouseDownHandler) dojo.disconnect(mouseDownHandler); mouseDownHandler = dojo.connect(map, "onMouseDown", mouseDown); };
watchMouseMoveAfterDown();
if (!mouseMovedAfterDown && geometry.type !== "point") { geometry = geometry.getCentroid(); }