Had a bit of a problem today trying to set a multi-scale image with a deep zoom source to fit the height. Fitting the width is easy:
That is right you are just setting the viewport width to 1 which makes sense!! But unfortunately there is no such thing as a viewport height. So another way is required:
As noted in the notes, this only works if the images are in a nice gridded layout. I guess you can modify it to work with the left hand most image of each row.
It basically works by looping over each sub image. Seeing if that image is on a new line, if it is record its origin y co-ordinate.
For any subsequent rows, work out the gap between the bottom of the image in the row above, and add those dimensions to a running total.
You can work out the height of a sub image simply by
Finally this running total for the height over the size of the multi source image element should give you the viewport width you require.
Setting the viewport origin to 0,0 will also make it line up in the element box nicely.