I have an image which I rotate by dragging a marker. To continue dragging from same position where user has left dragging previously, I am setting the coordinates of marker to lastRotationPoint.
Here is my code:
rotateMarker.on('mousedown', (e) => {
if(lastRotationPoint){
rotateMarker.setLatLng(lastRotationPoint)
}
});
rotateMarker.on('drag', (e) => {
const newPos = rotateMarker.getLatLng();
prevPoint = imageLayer.getCenter();
if (lastRotationPoint) prevPoint = lastRotationPoint;
const newAngle = calculateAngleDelta(map, imageLayer.getCenter(), prevPoint, newPos);
const angDeg = radians2degrees(newAngle);
imageLayer.setAngle(angDeg, 'deg');
});
rotateMarker.on('dragend', (e) => {
saveImage();
lastRotationPoint = e.target.getLatLng();
img_center = imageLayer.getCenter();
destinationMarkerLoc = getDestinationMarkerLocation(img_center);
rotateMarker.setLatLng(
new L.LatLng(
destinationMarkerLoc.geometry.coordinates[1],
destinationMarkerLoc.geometry.coordinates[0],
),
{ draggable: 'true' },
);
});
Now rotation is working properly, but the problem is when I perform the mouse down event, marker is shifted to the previous position, but Cursor remains at the original marker postion.
I want the cursor to be on same position as the marker is.