Skip to content

Is there any methods in 2.x can be used to implement a function like useViewportState in 3.x? #452

Closed Answered by rsimon
Songhao-LI asked this question in Q&A
Discussion options

You must be logged in to vote

It's certainly possible. But not trivial to implement. You'd need to listen to the update-viewport event on the OpenSeadragon viewer, then determine the current viewport bounds (using OpenSeadragon's API) in the coordinate space of the base image, and finally filter all annotations based on whether they intersect the bounds.

If you are not expecting to have many annotations, then simply looping through all annotations will work. (If you expect to have many, you'd probably have to build a 2D index and keep it in sync as annotations are added, updated and removed. Annotorious v3 does that. But it's probably not necessary unless you go over several 100 if not 1000 annotations.)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Songhao-LI
Comment options

Answer selected by Songhao-LI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants