Closed dianamarginean closed 1 year ago
The mouse coordinates are relative to your viewport, or the DOM element you are attaching the listener to (depending on which properties of the event you are using - offsetX
, clientX
etc.). The coordinates used by Annotorious (and on the SVG layer) are relative to the image's original size.
To compare, you need to convert the mouse coordinates to image coordinates (or vice versa), using OpenSeadragon's built-in functions, and compare then. See e.g.: https://openseadragon.github.io/docs/OpenSeadragon.Viewport.html#viewerElementToImageCoordinates
P.S.: Depending on what it is you want to do, there might be more efficient ways to achieve your goal. If you are comparing against a lot of annotations, things might get slow. AnnotoriousOSD already uses a 2D-index internally, and could do fast intersection checking for example. All a bit undocumented though...
@rsimon thank you it worked
Hi.
I'm using Annotorius with OSD and faced the following problem I currently want to get the {X,Y} coordinates of a mouse and compare it with a point from a SVG polygon. I added an different events on: canvas, svg, document, but the coordinates are very little comparing with the ones from the points from the svg points.
As an example my mouse point coordinates when clicking inside a polygon is
The points from the svg polygon are
The difference between the 2 coordinates is a range between [10.000 - 20.000]. why is the cause of this?
Any Ideas? I also tried to modify the mouse coordinates by multiplying it with 100 or followed these links, but with no success https://stackoverflow.com/questions/10298658/mouse-position-inside-autoscaled-svg