annotorious-openseadragon
annotorious-openseadragon copied to clipboard
Firebase plugin is not working with OSD and dynamic tile sources
Steps to replicate: Set up an OpenSeadragon instance using a dynamic tile source, initialize the Annotorious OSD plugin. Try to load the Firebase plugin.
Error: When annotations are saved, they're always saved as the base URL plus "undefined".
This seems to be due to Firebase using the URL from OSDAnnotationLayer.js (lines 66+67):
const src = this.viewer.world.getItemAt(0).source['@id'] ||
new URL(this.viewer.world.getItemAt(0).source.url, document.baseURI).href;
In our OSD implementation, this.viewer.world.getItemAt(0).source.url is undefined. This can be worked around by setting it prior to calling Firebase - that has to be done in TileDoneHandler to make sure that source is defined, as it's only defined when OSD actually puts something in the canvas:
var tileDrawnHandler = function(event) {
viewer.removeHandler('tile-drawn', tileDrawnHandler);
viewer.world.getItemAt(0).source.url = <URL>
I suspect this is because our OSD tile source isn't a file - we're loading tiles from S3-storage as we need them.
var viewer = OpenSeadragon({
id: "openseadragon1",
prefixUrl: "https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/",
navigatorAutoFade: false,
showNavigator: true,
zoomInButton: "zoomIn",
zoomOutButton: "zoomOut",
homeButton: "home",
fullPageButton: "fullscreen",
gestureSettingsTouch: {
pinchRotate: true
},
success: function(event) {
imageDone = true;
},
tileSources: {height: 243848,
width: 106312,
tileSize: 2048,
overlap: 1,
getTileUrl: function( level, x, y ){return "<URL>"+ level + "/" + x + "_" + y + ".jpg";
}
}
});
I suspect OSD isn't setting source.url because there's no one URL for the source - we get the tiles as we go along.